練習33 - whileループ

 

 

I = 0 
番号 = [] 

ながら iが6 < 印刷" 上部でiは%dです"%のI)
    numbers.append(I)
    
    I = I + 1
     プリント" 今番号:" 、数字)
     印刷" 一番下には私は%dです"%のI)
    
    
プリント" :数字" 

のための NUM 番号:
     プリント(NUM)

出力

上部にiがある0 
数字は今:[0] 
下で私がある 1 
iが最上部にある 1つの
今番号:[0、 1 ] 
下で私がある 2 
iが最上部にある 2つの
今番号:[0、 1、2 ] 
下部に私がある 3 
iは、上部にある 3つの
今数:[0、 1、2、3 ] 
下で私がある 4 
iが上部にある 4つの
今番号:[0、 1、2、 3、4 ] 
iの下部にあります5 
iは、上部にある 5つの
今番号:[0、 1、2、3、4、5 ] 
下で私がある 6つの
番号:
0
 1 
2 
3 
4 
5

 forループ

numbers = []

for i in range(0, 6):
    print("At the top i is %d" % i)
    numbers.append(i)
    
    i += 1
    print("Numbers now: ", numbers)
    print("At the bottom i is %d" % i)

    
print("The numbers: ")

for num in numbers:
    print(num)

 

2019-09-30

17:43:27

おすすめ

転載: www.cnblogs.com/petitherisson/p/11612215.html