Learn String Manipulation by Building a Cipher - Step 50

Tell us what’s happening:

Describe your issue in detail here.

Step 50

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

What does it mean by passing A as arguments to the function call. Cheers in advance.

Your code so far

/* User Editable Region */

text = 'Hello Zaira'
shift = 3

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

    for char in message.lower():
        if char == ' ':
            encrypted_text += char
            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('message:', text, 'offset:', shift)

### Challenge Information:
Learn String Manipulation by Building a Cipher - Step 50

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.

Hello Raven,

So the question meant that you should only eddit the function call. Before you do anything the function call looks as followed caesar() on the bottom of your code. But without the proper argements (text and shift) it’s not going to be able to do anything. If you pass them in there you should be able to see the code working in the preview window on the right.

So for now, if you can change the function definition back. And then in the function call just pass in the 2 parameters you should be able to get it. If not please show your adjusted code and we’ll help you further.


Why is it that if we rearrange the arguments, rather than text and shift we used shift and text it won’t run?

How will Python know you’ve switched the order? It matches the arguments (given when you call the function) to the parameters (the variables you set up in the definition) by the order.

caesar(text, shift):

         ||         ||
         \/         \/

def caesar(message, offset):

You can read a bit more about positional arguments here:

1 Like