我只是讓自己習慣於如果在python中的其他語句,但我有一些麻煩試圖讓我的工作,究竟發生了什麼?爲什麼我的if else語句不正確?
x = input("Enter your string")
while not set(x).issubset({'m', 'u', 'i'}):
print("false")
x = input("Enter your string")
else:
print("Your String is " + x)
Question = int(input("Which rule would you like to apply? enter numbers 1-4: "))
if Question is 1:
print("hello")
'''issue arises in the else area below'''
else if Question is not 1:
print("other")
您不應該使用'is'來比較數字。 – JBernardo
@JBernardo,是的,但這並沒有引起這個問題的問題 – Holloway
如果你正在使用它來重新檢查你剛剛檢查過的同樣的條件,那麼'elif'是多餘的。 – khelwood