Learn String Manipulation by Building a Cipher - Step 68

Tell us what’s happening:

hi !
I did call the function passing text and custom_key as the arguments. but don’t know how to store the return value of the function call in a variable called encryption.

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

    vigenere(text,custom_key)
        encryption = return

# 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/18.0 Safari/605.1.15

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 68

put it in the global scope, so not indented, so not space at the beginning of the line.

Now, if you have to give the value of 1 to the variable encryption how would you do that?

sorry I’m new to this ,
encryption = 1 ?

perfect! Now, to give the output of a function to encryption, just put the function call in place of the 1

so
encryption = vigenere (text, custom_key) ?

try that, what happens?

1 Like

it worked ! thank youuu XD
but what is the return value then ?

the return value of a function is what the function is evaluated to when called. In this case it is wcesc mpgkh

1 Like

okey , thank you again for your help :wink: