Learn String Manipulation by Building a Cipher - Step 84

Tell us what’s happening:

It says Im missing an argument no matter the order I put them in. Clearly theres something Im overlooking, but I cant seem to find it myself.

Your code so far

text = 'Hello Zaira!'
custom_key = 'python'

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

    for char in message.lower():

        # Append any non-letter character to the message
        if not char.isalpha():
            final_message += char
        else:        
            # Find the right key character to encode/decode
            key_char = key[key_index % len(key)]
            key_index += 1

            # Define the offset and the encrypted/decrypted letter
            offset = alphabet.index(key_char)
            index = alphabet.find(char)
            new_index = (index + offset*direction) % len(alphabet)
            final_message += alphabet[new_index]
    
    return final_message

# User Editable Region

def vigenere(key, encrypt, message):
    pass

encryption = vigenere(text, custom_key)
print(encryption)
decryption = vigenere(encryption, custom_key, -1)
print(decryption)

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 84

You have changed this:

def encrypt(message, key):
    pass

To this:

What you should do is replace the pass keyword from the encrypt method with a return statement which calls the vigenere method, as described in the instructions.

1 Like

You’ve overthinking this. The vigenere function has already been defined. I would reset the challenge.

From there, I would delete the pass keyword inside the encrypt function; which was created last step. Then I would return vigenere(message, key) from the encrypt function.

Hope this helps.

1 Like

Thanks I keep reminding myself in the notes I take that I am overthinking.