Learn String Manipulation by Building a Cipher - Step 50

Hi guys, and again got stuck here where the condition is:
Give message and offset values, by passing text and shift as arguments to the caesar function call.

I replaced the Text and shift variable names by message and offset above the fundction caesar, holding the old values however, system doesn’t allow pass me throw sending the error: You should pass text and shift as the arguments to your function call.

Thank you in advance for your help

Your code so far


/* User Editable Region */

message = 'Hello Zaira'
offset = 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)

caesar()

/* 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/120.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 50

Replacing is not needed here. There’s only one place in code that’s calling the caesar function. Are you able to point to it?

2 Likes

you mean calling the caesar(message, offset) end the code ?

no, calling the caesar function execute the function, it doesn’t end the code. You need to call the function with arguments tho

Sorry, looks like cannot get the point.
Before calling the function ceaser() we can also add the message and offset variables assigning to them the old or new values. did you mean that or anything else ?

Here you are calling the caesar function with no arguments. It has nothing to pass, nothing to process.

Here I call a function called pasta with 2 arguments to pass on and process.

pasta("Hello there", 15);

def caesar(message, offset):
Here you have defined caeser to accept 2 arguments and assign them to the variables message and offset for further processing in the body of the function

2 Likes

text and shift are the values you pass as arguments to the message and offset function parameters.

arg1 = 'Value 1'
arg2 = 'Value 2'

def fn(param1, param2):
  #whatever

fn(arg1, arg2)
2 Likes

Thanks a lot, the step is pass. Seems i understood the condition a bit in wrong way. Thank you for explanation

1 Like

Good hint! I was able to figure it out.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.