码迷,mamicode.com
首页 > 其他好文 > 详细

用for循环写这段代码

时间:2020-02-28 16:04:47      阅读:59      评论:0      收藏:0      [点我收藏+]

标签:more   else   bre   too   color   print   inpu   span   bye   

之前用while循环写了一段代码,现在改为用for循环来写,代码如下:

 

hongtao_age = 38
for i in range(5):
    guess_age = int(input("Please guess the hongtao‘s age:  "))
    if guess_age == hongtao_age:
        print("================")
        print("Yes!you get it!!Good Bye!!")
        print("================")
        break
    elif guess_age < hongtao_age:
        print("You need guess more.....")
    else:
        print("less you guess..........")
else:
    print("====================================")
    print("You guess too much time!!  Fuck off !!")
    print("====================================")

 

用for循环写这段代码

标签:more   else   bre   too   color   print   inpu   span   bye   

原文地址:https://www.cnblogs.com/show530/p/12377163.html

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