Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- MAX_KEY_SIZE = 26
- getMessage = input("Enter the coded message: ").lower()
- def translation():
- 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):
- print("calculation in progress...")
- time.sleep(3)
- while True:
- message = getMessage
- translated = ''
- for symbol in message:
- if symbol.isalpha():
- num = ord(symbol)
- num += key
- if symbol.islower():
- if num > ord('z'):
- num -= 26
- elif num < ord('a'):
- num += 26
- translated += chr(num)
- else:
- translated += symbol
- return translated
- #return translated
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement