看书自学 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!
百思不得其解,请指点一下,感谢!