Python-练习 while 和for 循环
1 # while 循环 2 age = 56count = 0 3 while count < 3 : 4 guess_age=int(input('输入年龄:')) 5 if guess_age == age: 6 print('猜到了') 7 break 8 elif guess_age > age: 9 print('猜大了') 10 else: 11 print('猜小了') 12 count +=1 13 if count==3: 14 shuru=input('还玩吗(Y/N)') 15 if shuru != 'n': 16 count =0 17 else: 18 print('以输入3次,告辞') ''' 19 20 #从0开始循环,最大到10,步数是2 21 for i in range(0,10,2): 22 print(i) 23 24 25 for i in range(10): 26 print('---',i) 27 for j in range(10): 28 print(j) 29 if j >5: 30 break 31 32 学习无止境,加油