Learn-string-manipulation-by-building-a-cipher - Step 86

Good day.
Please I need help.
I have deleted encryption and it’s value pass text to the first argument to decrypt
yet me code is still not passing
text = ‘mrttaqrhknsw ih puggrur’
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
        # 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

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

def decrypt(text, message, key):
return vigenere(text, message, key, -1)

print('Encrypted text: ’ + text)
print('Key: ’ + custom_key)
decryption = decrypt(encryption, custom_key)
print('Decrypted text: ’ + decryption)

Hello Emma,

You did indeed delete the encryption variable, but you are still using it in your decryption variable. The second part of the question was to pass text as the first argument to decrypt right now your arguements for decrypt are encryption, custom_key I don’t see text there.

1 Like

Ok I see. Thanks let me try it out.
You mean this line " decryption = decrypt(encryption, custom_key)" right?

Yes indeed. If it still doesn’t work, please let me know and show us the code again. :slight_smile:

1 Like

I am cool with it now. Thanks a lot.


you forgot to change encrypted to text

It’s wrong, on line three you have to change encryption to text


It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.