Caesar Cipher



letters =
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']

combo_display = [letters + numbers + symbols]
print(combo_display)
def Encrypt(message, shift):
cipher = ''
for char in message:
if char == ' ':
cipher = cipher + char
elif char.isupper():
char.lower()
cipher = cipher + chr((ord(char) + shift - 65) % 26 + 65)
else:
cipher = cipher + chr((ord(char) + shift - 97) % 26 + 97)

print(f"Your original message was: {message}\nThe encrypted text is {cipher}")
codeIt()

def Decrypt(message, shift):
cipher = ''
for char in message:
if char == ' ':
cipher = cipher + char
elif char.isupper():
char.lower()
cipher = cipher + chr((ord(char) - shift - 65) % 26 + 65)
else:
cipher = cipher + chr((ord(char) - shift - 97) % 26 + 97)
print(f"The decrypted text is {cipher}")
codeIt()

def codeIt():
direction = input("Type 'encode' , 'E' or 'e' to encrypt, type 'decode', 'D' or 'd' to decrypt:\n")
message = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))

if direction == "encode" or direction == "E" or direction == "e":
Encrypt(message, shift)
elif direction == "decode" or direction == "D" or direction == "d":
Decrypt(message, shift)

codeIt()