Hi everyone,
I’m stuck on Step 70 of the Vigenère Cipher project. I’ve added the third parameter direction to the function and commented out the last two lines exactly as instructed, but it still says “Your code does not pass.”
I’ve tried resetting and rewriting carefully, but can’t figure out what’s wrong.
Any guidance would be really appreciated!
Thank you in advance
Your code so far
# User Editable Region
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) % len(alphabet)
encrypted_text += alphabet[new_index]
return encrypted_text
#encryption = vigenere(text, custom_key, 'encode')
#print('encrypted text:', encryption)
# 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/137.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 70
Hi, I’m stuck on Step 70 of the Vigenère Cipher project.
I have followed all the instructions carefully:
I added the third parameter direction to the function definition.
I did not change the last two lines — I only added # in front of them to comment them out exactly as they were.
But I’m still getting this error:
Sorry, your code does not pass. You’re getting there.
You should turn the last two lines in your code into comments. Put a # at the beginning of each line.
I’ve even tried resetting the code and carefully retyping it. Still the same error.
Can someone please help me figure out what might be going wrong?
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Hi everyone, I just wanted to follow up — I’ve tried to format everything as instructed using triple backticks.
I’m stuck at Step 70 of the Caesar Cipher → Vigenère project. I’ve added the third parameter (direction) and commented out the last two lines as requested, but it still says my code is incorrect.
I’ve pasted my current version of the code above.
Would appreciate any help or insight to figure out what I’m missing!