Tell us what’s happening:
i am no getting this
please help me
as i am not getiing
Your code so far
# User Editable Region
text = 'Hello Zaira'
custom_key = 'python'
def vigenere(message, key, direction="encode"):
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)
if direction == "encode":
return encrypted_text
# Example usage (commented out)
# encryption = vigenere(text, custom_key, "encode")
# print(encryption)
# decryption = vigenere(encryption, custom_key, "decode")
# print(decryption)
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 70