Home > Backend Development > Python Tutorial > Python syntax exercise--while loop

Python syntax exercise--while loop

黄舟
Release: 2016-12-28 17:25:06
Original
1766 people have browsed it

age = 26  
count = 0  
  
while count < 4:  
    intput = int(input("请猜猜我的年龄:"))  
    if intput < age:  
        print ("输入过小,请重新输入")  
    elif intput > age:  
        print ("输入过大,请重新输入")  
    elif intput == age:  
        print ("答案正确,游戏退出")  
        break  
    count = count + 1  
    print count  
else:  
    print ("输入错误超过3次,游戏退出")
Copy after login

The above is the content of Python syntax exercise-while loop. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template