Python語法練習--while循環
來源:懂視網
責編:小采
時間:2020-11-27 14:27:08
Python語法練習--while循環
Python語法練習--while循環:age = 26 count = 0 while count < 4: intput = int(input("請猜猜我的年齡:")) if intput < age: print ("輸入過小,請重新輸入") elif intput > age: print ("輸入過大,請
導讀Python語法練習--while循環:age = 26 count = 0 while count < 4: intput = int(input("請猜猜我的年齡:")) if intput < age: print ("輸入過小,請重新輸入") elif intput > age: print ("輸入過大,請

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次,游戲退出")
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
Python語法練習--while循環
Python語法練習--while循環:age = 26 count = 0 while count < 4: intput = int(input("請猜猜我的年齡:")) if intput < age: print ("輸入過小,請重新輸入") elif intput > age: print ("輸入過大,請