出现输入错误问题 只是给他们选择他们想要输入的内容而不是是或否 代码:
def getMode():
while True:
print('do you wish to encrypt or decrypt a message?')
mode = input().lower()
if mode in [ 'encrypt', 'e', 'decrypt', 'd']:
return mode
else:
print('Enter either "encrypt or "e" or "decrypt", "d".')
错误:
Traceback (most recent call last):
File "/Users/gomcrai/pythings/caesarCipher.py", line 46, in <module>
mode = getMode()
File "/Users/gomcrai/pythings/caesarCipher.py", line 8, in getMode
mode = input().lower()
File "<string>", line 1, in <module>
NameError: name 'e' is not defined
只有第46行发生的事情就是调用函数