首頁  >  文章  >  後端開發  >  Python語法練習--while循環

Python語法練習--while循環

黄舟
黄舟原創
2016-12-28 17:25:061667瀏覽

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中文網(www.php.cn)!


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn