python 猜年龄控制猜的次数 for循环

此代码用python 3.6写的。2.几版本可能会出错
age_of_boy =44


count =0
while count<3: #首先允许用户猜三次
guess_age =int(input('guess age:'))

if guess_age ==age_of_boy:
print('yes,you get it')
break #猜对结束循环
elif guess_age>age_of_boy:
print('think smaller...')
else:
print('think bigger...')
count +=1
if count ==3:
guess_confirm =input('do you want to continue...')
if guess_confirm !='n':
count =0 #用户猜三次没对后询问是否继续

for循环
for i in range(0,10,2):
print(i) #输出0,2,4,6,8 2是间隔


posted @ 2018-05-15 21:33  呦呦呦呵呵呵  阅读(298)  评论(0编辑  收藏  举报