試圖修復一些代碼:故障與如果和多個整數
function():
answer = int(input("Write a number"))
if answer == 101:
print("You found a secret!")
do_stuff()
elif answer >= 5 and answer <= 100 and answer >= 102:
print("This is not a valid option!")
function()
else:
continue with other inputs
這是專門的elif的答案> = 5(等)是不正常的,它只是轉移到了別的:其他投入,我不知道如何解決它。
你什麼時候認爲'答案'小於100 **而**大於102? –
一個數字不能同時在5到100之間,也大於102! – sgrg
我懷疑你只是指'elif answer> = 5',因爲第一個案例已經排除了'101'。 – khelwood