首页 > 编程语言 > 详细

python 入门 guess 函数

时间:2018-05-21 11:03:11      阅读:1165      评论:0      收藏:0      [点我收藏+]

猜年龄限制次数,使用while函数和count计数器。

age_of_spencer = 28
count = 0
while True:
    if count == 2:
        break
    age = int(input("age:"))
    if age == age_of_spencer:
        print("you made it")
        break
    elif age >= age_of_spencer:
        print("too big")
    else:
        print("too small")
    count = count + 1
if count==2:
    print("you had tried too many times")

 

python 入门 guess 函数

原文:https://www.cnblogs.com/spencersun/p/9065849.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!