Hey!! so i tried my best with the Caesars Cypher but I am completely lost as to how to fix this error. If anyone have any suggestions please help!!
Thank You in advance
P.S : I am not sure if this is the right way to code this but it worked for string “hello” when i tested.
import string
alphabet = list(string.ascii_lowercase)
alphabet.append(" ")
alphabet.append("!")
alphabet.append(".")
alphabet.append("?")
message_to_decode = "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 encode(word, s):
new_word = []
text = []
for i in word:
char = alphabet.index(i)
text.append(char)
for i in text:
new_word.append(alphabet[i - s])
str_word = "".join(new_word)
return str_word
def decode(word, s):
new_word = []
text = []
for i in word:
char = alphabet.index(i)
text.append(char)
for i in text:
new_word.append(alphabet[i + s])
str_word = "".join(new_word)
return str_word
# encode("hello", 3)
decode(message_to_decode, 10)