Learn String Manipulation by Building a Cipher - Step 55

Tell us what’s happening:

I don’t know what the question is asking for, and I do not know how to go to the next step.

Your code so far

text = 'Hello Zaira'
shift = 3

def caesar(message, offset):
    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)
    print('encrypted text:', encrypted_text)

# User Editable Region

caesar()

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 55

It wants you to modify the caesar function call. The function is being called but an error is occurring because the function parameters aren’t receiving any values.

You need to pass both text and shift as arguments so that message and offset receive values.

1 Like

You need to pass both text and shift as arguments so that message and offset receive values.

How do you even pass them?
Like doing what specifically

Parameters are variables that act as placeholders for the values that are to be input to a function when it is called. When a function is defined, it is typically defined along with one or more parameters. The actual values that are input (or “passed”) into a function when it is called are known as arguments.

Does this help at all?

Parameters are variables that act as placeholders for the values that are to be input to a function when it is called. When a function is defined, it is typically defined along with one or more parameters. The actual values that are input (or “passed”) into a function when it is called are known as arguments.

It still doesn’t make sense… I need a clue about what to do

Hi @1302200651

Currently, your code raises a TypeError, because the caesar function is defined with two parameters (message and offset), therefore it expects to be called with two arguments.

Give message and offset values, by passing text and shift as arguments to the caesar function call.

For this step, call the caesar function, with text and shift between the parentheses.

text and shift are the function call arguments.

Happy coding

Did you read the linked page? If so, please tell me what you didn’t understand.

1 Like

Thank you!
Now I know what I was wrong!

1 Like

Also, Thank you for posting the link for FUNCTIONS @a2937