Learn String Manipulation by Building a Cipher - Step 68

Tell us what’s happening:

Im quite confused with what it’s asking me to do here. Just stuck. Would appreciate some help.

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
        else:        
            # 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

def vigenere (text, custom_key):
    encryption = ('encrypted_text')

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 68

you don’t call a function using def, you may want to review how calling a function work: https://www.freecodecamp.org/learn/full-stack-developer/lecture-introduction-to-python/how-do-functions-work-in-python

Thank you. However, I am still confused. Specifically with the second part.

what second part is that?

Sorry for not specifying. The second part of the question is what I meant to refer to.

what issue are you having with that part?

Where it mentions to store the return value of the function call in a variable called encryption.

and what issue are you having with that?

Knowing where to store the return value.

Hi @AspiringCoder04

The variable name given is the container for storing the value.

Happy coding

in a new variable named like written in the instructions

1 Like

Thank you guys. I was able to solve it. Looking back at it, the answer was in front of my face the ENTIRE time.

1 Like