Learn String Manipulation by Building a Cipher - Step 60

Tell us what’s happening:

What is wrong?

Your code so far


# User Editable Region

key_index = 0
text = 'Hello Zaira'
custom_key = 'python'
key_index(0)
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)
    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/145.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 60

hello and welcome to fcc forum :slight_smile:

  • check its “scope”, is it on local scope or global?
  • this step requires you to declare it within function scope

address that change and try again, happy coding :slight_smile:

i dont know what u mean and what i need to do

sorry​:cry:

Hi there,

Did the instructions ask you to do this?

Happy coding!

Step 60

Since your key is shorter than the text that you will have to encrypt, you will need to repeat it to generate the whole encrypted text. At the beginning of your function body, declare a key_index variable and set it to zero.

// running tests

  1. You should declare a variable called key_index at the beginning of your function body.
  2. You should assign 0 to your key_index variable.
    // tests completed