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

python之路-day1-while循环

时间:2017-04-22 12:26:50      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:code   got   无限   keep   author   any   int   think   hue   

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")

 

python之路-day1-while循环

标签:code   got   无限   keep   author   any   int   think   hue   

原文地址:http://www.cnblogs.com/wenwei-blog/p/6747285.html

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