编程语言
首页 > 编程语言> > python while循环简单例子

python while循环简单例子

作者:互联网

i = 1
while True:
    while i <= 3:
        age = int(input("input yout guess age:"))
        if age == 22:
            print("yes!")
        elif age < 22:
            print("no,your guess little!")
        elif age > 22:
            print("no,your guess old!")
        else:
            print("press error!")
        i += 1
    print("you are pig!")
    j = input("continue to guess? >: yes / no")
    if j == "yes":
        i = 1
        print(end = "")
    elif j == "no":
        break
    else:
        print("press error!")

标签:guess,no,python,else,while,例子,print,yes
来源: https://blog.csdn.net/qq_44008364/article/details/122800734