Learn String Manipulation by Building a Cipher - Step 60

Tell us what’s happening:

I have declared the variable, but still It doesn’t pass

Your code so far


# User Editable Region

key_index = '0'
text = 'Hello Zaira'
custom_key = 'python'

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

    for char in message.lower():
        if char == ' ':
            encrypted_text += char
        else:
            index = alphabet.find(char)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    print('plain text:', message)

# User Editable Region

    print('encrypted text:', encrypted_text)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 60

You declared the variable with string data type and in the wrong place. Please read the instructions again.

It says at the beginning of the function body, I tried but still can’t do it

The function body starts on the line after the function definition:

2 Likes

Hi @Soul1,

You’re looking to declare the variable inside the function. Make sure to declare the integer 0, not a string '0'.

I hope this helps. Happy coding!

Thank you for Informing me about this

Yea thank you, I understood now

1 Like