看書自學 python
沒想到第一個習題就卡關
題目:
Write code that prints Hello if 1 is stored in spam,
prints Howdy if 2 is stored in spam, and prints Greetings!
if anything else is stored in spam.
我寫的 code:
spam = input()
if spam == 1:
print('Hello')
elif spam == 2:
print('Howdy')
else:
print('Greetings!')
問題:
程式可以順利執行,但不管我輸入1、2還是其他數字
出來的結果都是 Greetings!
百思不得其解,請指點一下,感謝!