Learn String Manipulation by Building a Cipher - Step 54

Hi community, I’m certain what the issue is here.

I keep getting an error message

Your code so far

text = 'Hello Zaira'
shift = 3

def caesar(message, offset, text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_text = ''

    for char in message.lower():
        if char == ' ':
            encrypted_text += char
        else:
            index = alphabet.find(char)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    print('plain text:', message)

# User Editable Region

    print('encrypted text:', encrypted_text)
caesar(text, shift)

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 54

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hi @MthoM
You modified the caesar function arguments.

The instructions did not ask you to do this.
You correctly passed the arguments to the caesar call.

Happy coding

Hi, I was struggling with the same to understand why read this.

In my own words when we declare the function we assign only the parameters that we need and we must pass the values of text and shift so it will be like this.
def caesar(message=text, offset=shift):

The rest of your code is correct.

But at the moment of calling the function, we should call it using the arguments that we need which for this example are text and shift.

caesar(text, shift)

Hope this works and clarify, also if I say something incorrect please correct me.

1 Like

Hello, from my console which works.
— removed—

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.