Learn String Manipulation by Building a Cipher - Step 58

Tell us what’s happening:

im pretty sure i did it right but i cant find the answer

Your code so far


# User Editable Region

text = 'Hello Zaira'
custom_key = 'python'

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

    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)
    print('encrypted text:', encrypted_text)

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 58

Hi @

You should declare a variable called key_index at the beginning of your function body.

Try putting the variable declaration at the top of the function body.

Happy coding


it still isnt wroking

Hi @kazimoyaz2

key_index is currently the third variable in the function body.

image

Happy coding

You should reload you web page and reset the step 58. When I input your code in its perfectly good for step 58 and 59. If your still having this problem idk whats wrong.