Learn String Manipulation by Building a Cipher - Step 84

Tell us what’s happening:

I browsed through relevant QnAs regarding this issues. One of the staff mentioned removing the spaces. Which spaces are you referring to? I have tried to remove some but to no avail. Can you assist me on how to rectify this issue? Thanks

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 encrypt(message, key):
    return vigenere(message, key)
    
def decrypt(message, key):
    return vigenere(message, key, -1)

encryption = encrypt(message, key)
print(encryption)
decryption = decrypt(message, key)
print(decryption)

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 84

The problem has nothing to do with spaces, but it is in the argument lists.

Hint: take a look at the argument list of the vigenere function in the original code:

encryption = vigenere(text, custom_key)

The same problem is also in the decrypt function:

Reset your code and try again.

I should replace the arguments list in the vigenere function with the initial variables?

def encrypt(message, key):
    return vigenere(message, key)

message and key are just parameters (think of them like general names) we use to define the encrypt function.

Now, to put the encrypt function to use, we have to pass arguments (real values) to it, instead of parameters.


In the original code:

encryption = vigenere(text, custom_key)

we used text and custom_key as arguments for the vigenere function.

Now, what are we gonna use as arguments for the encrypt function?
What is the message, and what is the key here?

encryption = encrypt(_____, ______)