Learn String Manipulation by Building a Cipher - Step 67

text = 'Hello Zaira'

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

#####as i call the function it raises an error message. please help.

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.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

What is the error message?

Hi @vyasmadhav45

Call your function passing text and custom_key as the arguments.

Your code has a string and a number as the arguments.

Happy coding

cant find any solution , please try to help

Call your function passing text and custom_key as the arguments
you are passing (“hello” , 7)
and maybe try resetting the code you only need to make the variable ‘encryption’ and asign it vigenere(message, key) with the proper arguments

Please post your new code