Learn String Manipulation by Building a Cipher - Step 67

Tell us what’s happening:

Hello, I tried this step for a plenty of time already I cannot pass this step 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 = return vigenere

# 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/121.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 67

Hello srmttmplz,

Right now you are defining the vingenere function again. You already have this function so you don’t have to define a new one. Instead you want to call the function.

A good example would be the print function. To call the print function and give it input you would write something like print(string_var). You will have to do something similiar with vigenere.

I’m still confused because I have to create new variable as well which is “encryption”. Thus, I dont need to define new vigenere but to use print function?

You never have to define it again. Defining a function is to make that code reusable so you can call it and you don’t have to write it again.

Many functions return a value. To store that value in a variable use this syntax

variable = function(argument1, argument2)

When I write
encryption = print(text, custom_key)
Its popped up “You should call vigenere passing text and custom_key as the arguments.”

you are calling print there, not vigenere, try calling vigenere

1 Like

omg, 20 min i have smashing my brains out. thx thx thx

I got it now!! Thank you so much!