Python语法练习--while循环

黄舟
黄舟 原创
2016-12-28 17:25:06 1394浏览
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次,游戏退出")

以上就是Python语法练习--while循环的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!


声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。