當我運行這段代碼時,它總是進入else
。即使我選擇1,2或3.我怎樣才能達到正確的if, elif else
陳述?簡單的elif語句
def main():
name = input("What is your name?")
print("Hello", name)
choice = int
choice = 0
choice = input("Please choose a number from the following options: \n 1. Paper \n 2. Rock \n 3. Scissors")
print (choice)
if choice == 1:
print ('You chose number 1')
elif choice == 2:
print ('You chose number 2')
elif choice == 3:
print ('You chose number 3')
else:
print ('Invalid Entry Mush')
return
main()
的編程語言是這樣嗎? – Beginner
請標記爲Python。腳本中有一些不必要的代碼行,但問題是輸入是字符串而不是整數。用引號將這些數字包裝在條件中。 –