python_while循环

# !/usr/bin/env python
# -*-coding:UTF-8-*-

older_age = 46



n = 0
while n < 3:
    guess = int(input("Guess_age:"))
    if guess == older_age:
        print("You are right!")
        break
    elif guess > older_age:
        print("Your guess is so big!")
    else:
        print("Your guess is so small!")
    n = n+1
else:
    print("You guess so many times! ")

这里用while循环实现猜年龄的小游戏。

发布了55 篇原创文章 · 获赞 11 · 访问量 2606

猜你喜欢

转载自blog.csdn.net/zuefeng/article/details/105166488