您的位置:首页 > 编程语言 > Python开发

python之路-day1-while循环

2017-04-22 11:27 357 查看
while Thue: (条件为真无限循环) break(跳出循环)

猜年龄:

#Author:zww
age_of_jay = 40
count = 0
while count < 3:
guess_age = int(input("guess_age:"))
if guess_age > age_of_jay:
print("think smaller...")
elif guess_age < age_of_jay:
print("think bigger...")
else:
print("yes,you got it!")
break
count +=1
if count == 3:
conutine_confirm = input("do you want to keep guessing...?")
if conutine_confirm != "n":
count = 0
else:
print("you have tried too many times...fuck off")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: