Tell us what’s happening:
im stuck on step 70 it keeps showing that its not correct and i should comment the last two and i did and it still shows incorrect
Your code so far
# User Editable Region
text = 'Hello Zaira'
custom_key = 'python'
def vigenere(message, key, direction='encrypt'):
key_index = 0
alphabet = 'abcdefghijklmnopqrstuvwxyz'
result_text = ''
for char in message.lower():
if char == ' ':
result_text += char
else:
key_char = key[key_index % len(key)]
key_index += 1
offset = alphabet.index(key_char)
index = alphabet.find(char)
if direction == 'encrypt':
new_index = (index + offset) % len(alphabet)
elif direction == 'decrypt':
new_index = (index - offset) % len(alphabet)
else:
pass
result_text += alphabet[new_index]
return result_text
# encryption = vigenere(text, custom_key, 'encrypt')
# print(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/142.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 70