So I'm in the middle of making a simple Caesar cipher for practice and I can't get it to decipher entire strings, just individual letters.
symbol_add is the function in question.
Here's the code:
import re
alphabet = "abcdefghijklmnopqrstuvwxyz"
def cleanIt(clean):
    global alphabet
    s = re.sub('[^a-z]+', '?', str(clean))
    return s
def symbol_add(symbol, key):
    encryptedMsg = ""
    for x in symbol:
        position = alphabet.find(x)
        newPosition = (position + key) % 26
        newLetter = alphabet[nyPosisjon]
    encryptedMsg += nyBokstav
    return encryptedMsg
def cipher(data,key):
    text = ""
    if data in alphabet:
        text += symbol_add(symbol=data,key=key)
        return text
def main():
    try:
        msg = (input("Write the message you would like to encrypt\n"))
        key = int(input("which key would you like to use?\n"))
        cleanIt(clean=msg)
        print(cipher(data=msg, key=key))
    except ValueError:
        print("Write a number!")
main()
I'm sure the solution is pretty simple, still learning.
Any help in how to solve this will be greatly appreciated!
 
     
    