import pyperclip

message= input("Input a message: ")
key = int(input("Input a key: "))

mode = input("encrypt or decrypt? ")

SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?.'

translated = ''

for symbol in message:
	if symbol in SYMBOLS:
		symbolIndex=SYMBOLS.find(symbol)
		if mode == 'encrypt':
			translatedIndex = symbolIndex + key 
		elif mode == 'decrypt':
			translatedIndex= symbolIndex-key
		if translatedIndex >=len(SYMBOLS):
			translatedIndex = translatedIndex-len(SYMBOLS)
		elif translatedIndex < 0:
			translatedIndex=translatedIndex+len(SYMBOLS)

		translated = translated + SYMBOLS[translatedIndex]
	else:
		translated = translated + symbol

print(translated)
pyperclip.copy(translated)
