# Caesar-Cipher

Hi!
I came across the Caesar-Cipher project. In it I need to encode my message by shifting each letter 10 places to the right with respect to the alphabet. I can’t understand why the letters are so strange in the output list, because let’s say ‘x’ should change to ‘h’. But I have a blank ’ ’ instead.

It’s the project in Data Science Foundations called “Off-Platform Project: Coded Correspondence”.

arr_en = [‘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’];
message = “xuo jxuhu! jxyi yi qd unqcfbu ev q squiqh syfxuh. muhu oek qrbu je tusetu yj? y xefu ie! iudt cu q cuiiqwu rqsa myjx jxu iqcu evviuj!”

def caesar_cipher(message):
length = len(arr_en)
list =
for letter in message:
list.append(letter)
for letter in list:
if letter == " " or letter == “.” or letter == “!” or letter == “?”: # these symbols don’t need to be changed
list[number] = letter
else:
number = arr_en.index(letter) # found an index of a symbol in the alphabet
if number + 10 > length: # some symbols can be out of range in the alphabet,
rest = length - number # so we need to to a check
list[number] = arr_en[10-rest]
elif number + 10 < length:
list[number] = arr_en[10+number]
else:
list[number] = arr_en
return list
print(message)
print(caesar_cipher(message))

Hey there, here is my solution:

message = “xuo jxuhu! jxyi yi qd unqcfbu ev q squiqh syfxuh. muhu oek qrbu je tusetu yj? y xefu ie! iudt cu q cuiiqwu rqsa myjx jxu iqcu evviuj!”
alphabet = “abcdefghijklmnopqrstuvwxyz”
def decoder(message):
decoded = “”
for char in message:
if alphabet.find(char) == -1:
decoded += char
else:
if alphabet.find(char) + 10 < 25:
decoded += (alphabet[alphabet.find(char) + 10])
else:
if alphabet.find(char) + 9 >= 25:
decoded += (alphabet[(alphabet.find(char) + 9) % 25])
return(decoded)
print(decoder(message))