Learn String Manipulation by Building a Cipher - Step 86

Hey good afternoon I am stuck at this step and I have try reading the other comments about the other coders but i don’t get to pass this step can someone please guide me in the right steps and tell me a hit and let me know what am doing wrong please and thank you. …

Your code so far

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

# User Editable Region

***def decrypt(text, custom_key):***
***return vigenere(text, custom_key, -1)***

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

# User Editable Region

Here is a link to the website of this problem thank again.

Hi @skinnyboy21

Remove the triple asterisks around your code.

Happy coding

1 Like

You declared two times the same function here


thank @DobarBREND your a hero!