您好,登錄后才能下訂單哦!
條件判斷與縮進,注意冒號
加次數限制
#猜數字
lucky_num = 19
input_num = -1
#次數限制
count = 0
#while lucky_num!=input_num and count < 3:
while count < 3:
input_num = int(input("please input your lucky_num:"))
if input_num < lucky_num:
print("please input big num")
elif input_num > lucky_num:
print("please input little num")
else:
print("great")
break
count += 1
print(count)
else:
print("too many counts!!!!")
注意縮進,python是對縮進敏感的語言
注釋:ctrl+/
for循環
#次數限制
for i in range(3):
input_num = int(input("please input your lucky_num:"))
if input_num < lucky_num:
print("please input big num")
elif input_num > lucky_num:
print("please input little num")
else:
print("great")
break
else:
print("too many counts!!!!")
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。