码迷,mamicode.com
首页 > 其他好文 > 详细

while/for循环+if猜年龄

时间:2017-10-08 19:03:09      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:off   big   try   think   print   年龄   range   wan   +=   

_oldboy_age = 56
count = 0
while count <3:
guess_age = int(input("guess_age:"))
if guess_age == _oldboy_age:
print("yes ,you right!")
break
elif guess_age > _oldboy_age:
print("think smaller")
else:
print("think bigger")

count +=1
if count == 3:
confirm = input("Do want to keep guessing?")
if confirm != ‘n‘:
count = 0


else:

print("you have try too much times,get off!")



--------------------------------------------------------------
_oldboy_age = 56

for a in range(3):
guess_age = int(input("guess_age:"))
if guess_age == _oldboy_age:
print("yes ,you right!")
break
elif guess_age > _oldboy_age:
print("think smaller")
else:
print("think bigger")




else:

print("you have try too much times,get off!")

while/for循环+if猜年龄

标签:off   big   try   think   print   年龄   range   wan   +=   

原文地址:http://www.cnblogs.com/szchenh2010/p/7638035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!