码迷,mamicode.com
首页 > 编程语言 > 详细

python猜年龄

时间:2018-10-25 14:03:05      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:for   range   man   ==   think   python   big   trie   pytho   

#若输入年龄正确,完成循环,最多只能输入三次,停止本次循环(使用while循环)
age = 28
count = 0

while count<3:
_age = int(input("age:"))

if _age==age:
print("you got it!")
break
elif _age>age:
print("think smaller")
else:
print("think bigger")
count +=1
else:

print("you tried many times")
#若输入年龄正确,完成循环,最多只能输入三次,停止本次循环(使用for循环)
age = 28

for i in range(3):
_age = int(input("age:"))

if _age==age:
print("you got it!")
break

elif _age>age:
print("think smaller")

else:
print("think bigger")

else:
print("you tried many times")

python猜年龄

标签:for   range   man   ==   think   python   big   trie   pytho   

原文地址:https://www.cnblogs.com/mahaigang/p/9848976.html

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