Coded Communication Project

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
        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:
                asci = ord(letter)
                if (asci >= 97) and (asci <= 122):
                    asci += offset
                elif asci > 122:
                    new_asci = (asci % 122) + 96
                    new_asci += offset

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!

when having a syntax error, always check the line above as well:


do you see the problem?

Oh my goodness! Thank you. I always thought the error must be on the exact line. I will certainly check the line above from now on. Thank you so much!

No, especially not when parentheses are involved given that allows us to put code on multiple lines.