今天我学习了循环语句,发现while ....后也可以加else:的。以前我一直以为只有if...后有else:,呵呵。。
1 # author:zfp 2 3 age_of_zfp=38 4 count=0 5 while (count<3): 6 guess_age=int(input("guess age:")) 7 if guess_age==age_of_zfp: 8 print("yes,you got if.") 9 break 10 elif guess_age>age_of_zfp: 11 print("think smaller...") 12 else: 13 print("think bigger!") 14 count=count+1 15 else: 16 print("You have tried too many times...fuck off")