I am unable to input my code in the place above it is not accepting my input can someone help me in this?
Your code so far
# User Editable Region
text = 'Hello Zaira'
custom_key = 'python'
def vigenere(message, key):
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)
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/135.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 70
Thanks for the guidance i have followed your first step but unable to implement the second one can you show it with a pic it would be much more helpful
It seems you’ve already implemented the first step, which is great! To help with the second:
To comment out the last two lines, you can simply add a # symbol at the beginning of the lines. This will tell Python to ignore those lines when running the program.
If you need further clarification on the second step, feel free to ask. Happy coding!
Do not simply hand someone the solution to their problem. In doing so, you deprive them of the learning process. Instead, consider guiding them to reach the solution on their own
An example syntax of a comment would have been better in my view.
ok my bad again i have implemented the second step but unable to implement the first direction step can you help me in which step should i put that direction code line?
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)
#encryption = vigenere(text, custom_key) #print(encryption)
This is the code and i am not getting in which step do you want me to add this direction i am not getting the third parameter in the code can you please help me?
You’re very welcome!
I’m glad I could help you out. Keep up the great work, and if you ever need more assistance, feel free to reach out here in the forum, we’re always happy to help!
i am getting the error in step 71 even after typing the right input it says to multiply offset with direction in the new index but it is not accepting my input can you help me in that?