Python NameError: name 'encrypt' is not defined -
when attempt run says nameerror: name 'encrypt' not defined.
max_key_size = 26 def getmode(): while true: print('do wish encrypt or decrypt message?') mode = input().lower() if mode in "encrypt" 'e' 'decrypt' 'd'.split(): return mode else: print('enter either "encrypt" or "e" or "decrypt" or "d".')
from understand of code, 'encrypt' string value. need create list required string values , check whether mode variable matches value in list.
max_key_size=26 def getmode(): while true: mode=input().lower() if mode in ['encrypt','e','decrypt','d']: return mode else: print('enter either "encrypt" or "e" or "decrypt" or "d".')
if want use .split() method, following:
if mode in "encrypt e decrypt d".split()
Comments
Post a Comment