Hello! I am currently working on the Coded Communication project using Jupyter Notebooks.
I have been using trial and error to decipher the first message and have gotten really close to creating a full list which I can then .join() in order to make the message. My problem is that all of a sudden I am getting a syntax error on something which I am 97% sure is not an error. This is my code:
def caesar_decode(message, offset=0):
if offset == 0:
return message
else:
decoded_message = []
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']
for letter in message:
if letter not in letters:
decoded_message.append(letter)
else:
asci = ord(letter)
if (asci >= 97) and (asci <= 122):
asci += offset
decoded_message.append(chr(asci)
elif asci > 122:
new_asci = (asci % 122) + 96
new_asci += offset
decoded_message.append(chr(new_asci))
print(decoded_message)
The error comes up on the “elif asci > 22:” line towards the end. It says “SyntaxError: invalid syntax”. I know that a lot of my code is wordy, but I am just trying to solve the problem before simplifying and I can’t get passed this error. Please let me know if you have any ideas on things I can try or if you see the error in my syntax.
Thank you!