Learn String Manipulation by Building a Cipher - Step 68

Tell us what’s happening:

I understand that i need to add the third parameter, I added it in, however, it still states that my code is not passing.
This is what i have for the new parameter.
def vigenere(message, key, direction):

Your code so far

# User Editable Region

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
            # 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)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    return encrypted_text
encryption = vigenere(text, custom_key, direction)

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 68

Also, comment out the last two lines of code to avoid errors in the console.

And, although what you did makes sense and you’ll do that later, the instructions didnt ask you to update the function call with the new argument.

I am new to coding, if it doesn’t go where I put it in the code, where would it go? if that is not against community standards. And with commenting it out, would i just # (comment)? Sorry this is all new to me!

I actually got it, thank you, I think I was overthinking this

1 Like