用for循环写这段代码

之前用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("====================================")

 

posted @ 2020-02-28 14:45  洪韬  阅读(218)  评论(0编辑  收藏  举报