Learn String Manipulation by Building a Cipher - Step 68

Tell us what’s happening:

Idk what I am doing wrong I already commented and put the other parameter

Your code so far


# User Editable Region

text = 'Hello Zaira'
custom_key = 'python'

def vigenere(message, key):
    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)
            new_index = (index + offset) % len(alphabet)
            encrypted_text += alphabet[new_index]
    
    return encrypted_text

#encryption = vigenere(text, custom_key, direction)
#print(encryption)

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 17_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 68

direction is a parameter, not an argument. It goes in the definition, not the call.

Oooh, thank you! I am new learning python

No problem. Parameters and arguments can be a little confusing at first. You’ll get the hang of it soon enough.

Happy coding.