Learn String Manipulation by Building a Cipher - Step 71

Tell us what’s happening:

I am putting the correct input but still its not accepting can anyone help me in writing the correct code and pass this level?

Your code so far

text = 'Hello Zaira'
custom_key = 'python'

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

    for char in message.lower():
    
        # Append space to the message
        if char == ' ':
            encrypted_text += char
        else:        
            # 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)

# User Editable Region

            new_index = offset * direction

# User Editable Region

            encrypted_text += alphabet[new_index]
    
    return encrypted_text
    
#encryption = vigenere(text, custom_key)
#print(encryption)

Your browser information:

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 71

do not delete anything, reset the step

you need to add the multiplication as part of the existing expression, do not delete the existing expression

how can i do that can you please help me?

if you have an expression like 3 + 4 * (22 - 2) and you want to double the 2 inside the expression you would add * 2 next to the 2: 3 + 4 * (22 - 2 * 2), you need to do something similar

i am trying to make some point out of it but unable to get it can you please help me at what step i need to do that so that i can perform it and solve the issue.

Press reset to get the code back how it was.

You only need to add * direction in one place to the code that is already there. You have it right in your posted code above but you have deleted other code when you shouldn’t have. Suggest resetting the step

i have resetted the code and just seeing where can i add * direction to it

got it done thanks for the help

1 Like