Learn String Manipulation by Building a Cipher - Step 71

Tell us what’s happening:

Describe your issue in detail here.

Your code so far

text = 'Hello Zaira'
custom_key = 'python'

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

# User Editable Region

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

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 71

1 Like

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hi, welcome to the forum!
We see you have posted some code but did you have a question?

(You have not filled out the “Tell us what’s happening:” field above)

modify your function call passing 1 as the third argument

2 Likes

Sorry but I am new and I do no know how all works??
In this step I must do two things:
1 uncomment the last 2 lines which I did
2 I called the function like vigenere(‘message’, ‘key’, ‘direction += 1’) but doesn’t work…
I feel stupid…

Welcome
And dont say i’am stupid coding is a trip

All you have to do is

Frist Rest the step 
encryption = vigenere(text, custom_key)

Add 1 after custom_key Dont forget

,

1 Like

Thank you so much…It works. I didn’t see that the function call was the one after encryption =
Next time I need to ready properly the code. Thank you so much. I very happy to be here.

If it worked don’t forget to click that

Solution Button

i trully understand this felling, but we already reach the seventieth step.it’s a freaking victory, for us who started now.