Learn String Manipulation by Building a Cipher - Step 63

Tell us what’s happening:

Describe your issue in detail here.
I honestly don’t understand what to do hear not sure if I’m just blind but I’ve looked at other peoples posts and still don’t understand what to do so if someone can explain in more detail what to do and if I’m close to it cause I’ve tried for hours

thank you

Your code so far

text = 'Hello Zaira'
custom_key = 'python'

def vigenere(message, key):
    key_index = 0
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_text = ''

    for char in message.lower():
        # Append space to the message
        if char == ' ':
            encrypted_text += char
            # Find the right key character to encode
            key_char = key[key_index % len(key)]
            key_index += 1

            # Define the offset and the encrypted letter
            offset = alphabet.index(key_char)
            index = alphabet.find(char)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    return encrypted_text

/* User Editable Region */

vigenere(text , custom_key)
    encryption = return.vigenere

/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 63

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.

You should assign this

to encryption.
The return keyword can be used exclusively inside a function.

When you assign that function call to a variable, the variable stores the value returned by the function.

but when I change vigenere to encryption it says “You should call vigenere passing text and custom_key as the arguments.”

and when you say the return keyword can be used exclusively inside the function does that mean I have to use it in the ()

variable = function(argument, argument)

This is the syntax to call a function with arguments and assign the result to a variable

vigenere(text , custom_key)
    encryption = return.vigenere

Re-write these two lines into 1 line in the format above.

1 Like

return can be used only inside the definition of the function, meaning the function body. When you call a function, forget about the return, you cannot use it there.

If you get always the same hint, check the indentation of your code. In case of syntax errors you get always the first hint.

thank you so much, I understand it now thank you for explaining it better for me

Took me a few attempts to figure, but you stated the solution very well, thank you @pkdvalis

1 Like