标签:输入 range 用户 false continue exit str pre span
游戏规则:
1 age=18 2 count=True 3 while count: 4 5 for i in range(3): 6 guess_age=int(input(‘你猜我的年龄是多大:‘)) 7 if guess_age < age: 8 print(‘猜小了,往大里猜‘) 9 elif guess_age > age: 10 print(‘猜大了,往小里猜‘) 11 else: 12 print(‘恭喜你,猜对了‘) 13 exit() 14 else: 15 ans=input(‘错误次数过多,是否继续:Y/n -->:‘) 16 if ans ==‘Y‘ or ans == ‘y‘: 17 continue 18 elif ans == ‘N‘ or ans == ‘n‘: 19 count = False 20 else: 21 print(‘输入错误,导致直接退出‘) 22 count = False
标签:输入 range 用户 false continue exit str pre span
原文地址:http://www.cnblogs.com/yanglang/p/7126317.html