Шифр Цезаря.Можете дать совет.
SYMBOLS='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
MAX_KEY_SIZE=len(SYMBOLS)
def getMode():
while True:
print('Do you wish to encypt or decrept yur message?')
mode=input().lower()
if mode in:
return mode
else:
print('Enter eitherencrypt or e or decrept or d')
def getMessage():
print('Enter your message:')
return input()
def getKey():
key =0
while True:
print('Enter the key number (1-%s)' %(MAX_KEY_SIZE))
key = int(input())
if (key >= 1 and key <=MAX_KEY_SIZE):
return key
def getTranslatedMessage(mode, message, key):
if mode == ‘d’:
key = -key
translated = ''
for symbol in message:
symbolIndex = SYMBOLS.find(symbol)
if symbolIndex == -1:
translated += symbol
else:
symbolIndex += key
if symbolIndex >= len(SYMBOLS):
symbolIndex -= len(SYMBOLS)
elif symbolIndex < 0:
symbolIndex += len(SYMBOLS)
translated += SYMBOLS
return translated
mode = getMode()
message = getMessage()
key = getKey()
print('Your translated text is:')
print(getTranslatedMessage(mode, message, key))