# 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[0]
return list
print(message)
print(caesar_cipher(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!
[‘k’, ‘g’, ‘z’, ‘z’, ‘s’, ‘h’, ‘u’, ‘!’, ’ ’, ‘q’, ‘j’, ‘f’, ‘y’, ‘i’, ‘y’, ‘i’, ’ ’, ‘q’, ‘d’, ‘u’, ‘n’, ‘q’, ‘c’, ‘f’, ‘b’, ‘u’, ’ ’, ‘e’, ‘v’, ’ ’, ‘q’, ’ ’, ‘s’, ‘q’, ‘u’, ‘i’, ‘q’, ‘h’, ’ ’, ‘s’, ‘y’, ‘f’, ‘x’, ‘u’, ‘h’, ’ ’, ‘m’, ‘u’, ‘h’, ‘u’, ’ ’, ‘o’, ‘e’, ‘k’, ’ ’, ‘q’, ‘r’, ‘b’, ‘u’, ’ ’, ‘j’, ‘e’, ’ ’, ‘t’, ‘u’, ‘s’, ‘e’, ‘t’, ‘u’, ’ ’, ‘y’, ‘j’, ’ ’, ‘y’, ’ ’, ‘x’, ‘e’, ‘f’, ‘u’, ’ ’, ‘i’, ‘e’, ’ ’, ‘i’, ‘u’, ‘d’, ‘t’, ’ ’, ‘c’, ‘u’, ’ ’, ‘q’, ’ ’, ‘c’, ‘u’, ‘i’, ‘i’, ‘q’, ‘w’, ‘u’, ’ ’, ‘r’, ‘q’, ‘s’, ‘a’, ’ ’, ‘m’, ‘y’, ‘j’, ‘x’, ’ ’, ‘j’, ‘x’, ‘u’, ’ ’, ‘i’, ‘q’, ‘c’, ‘u’, ’ ’, ‘e’, ‘v’, ‘v’, ‘i’, ‘u’, ‘j’, ’ ’]

The Caesar Cipher algorithm shifts each letter in the message by 10 places to the right with respect to the alphabet. For example, the letter ‘x’ would be shifted to ‘h’. In the output list, you can see that ‘x’ has been shifted to ‘k’, which is 10 places to the right of ‘x’.

hope this helps!