Learn String Manipulation by Building a Cipher - Step 63

Tell us what’s happening:

plz help idk what to I am stuck here i already add increment of key_index but it still says ’ use += operator to add 1 to key_index in the else clause body" but I did
else:

        key_char += key[key_index % len(key)]
        key_index += 1
        index = alphabet.find(char)
        new_index = (index + 0) % len(alphabet)
        encrypted_text += alphabet[new_index]
        
print('plain text:', message)
print('encrypted text:', encrypted_text)

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():

# User Editable Region

        # Append space to the message
        if char == ' ':
            encrypted_text += char
        else:

            key_char += key[key_index % len(key)]
            key_index += 1
            index = alphabet.find(char)
            new_index = (index + 0) % 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/140.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 63

Hi @nusrathjahanjuhra294 and welcome to our community!

You have inadvertently edited the top line of code here:

Hit the Reset button to restore the starting code for this step and then add the second line again.