我想写一个python程序,但是当我输入s或S时,就出错了。
#!/usr/bin/python
phonebook = {}
while True:
option = raw_input('Welcome use pyphonebook: add(A) / search(S)?')
if option == 'A' or 'a':
print 'Add a contact'
name = raw_input('Enter a name:')
if phonebook.__contains__(name):
print 'Contact %s is already in phonbook' % name
else:
num = raw_input('Enter phone number:')
phonebook[name] = num
elif option == 'S' or 's':
print 'Search a contact'
name = raw_input('Enter a name:')
if name in phonebook:
print "%s's phone number is %s" % (name, phonebook[name])
else:
print 'Not found'
print phonebook
当我输入 S 或 s 时,它会打印“添加联系人”。为什么?