python 循环while和for in简单实例
python 循环while和for in简单实例
#!/uer/bin/env python # _*_ coding: utf-8 _*_ lucknumber = 5 b = 0 while b <3: print('guss count:',b) a = int(input('you guse number')) if a > lucknumber: print ('youaerbiger') elif a == lucknumber: print ('youare righet') break #跳出这个层级的循环 else : print ('you aer smaller') b +=1 #在while循环中,+=1 是必须循环体 else: print ("Too many retrys!") #________________________________________________ for i in range(3): a = int(input('you guse number')) #注意用int()表示输出的是 数字类型 if a > lucknumber: print ('youaerbiger') elif a == lucknumber: print ('youare righet') break else : print ('you aer smaller') else: print ("Too many retrys!")
相关推荐
elizabethxxy 2020-11-06
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20