Tell us what’s happening:
What’s wrong with this code I think they might be a system error here there’s nothing wrong with this code?
Your code so far
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
# User Editable Region
def encrypt(text, shift):
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
encrypted_text = ""
for char in text:
if char.upper() in alphabet:
is_upper = char.isupper()
char_upper = char.upper()
# Define the offset and the encrypted letter
offset = shift
index = alphabet.find(char_upper)
new_index = (index + offset) % len(alphabet)
if is_upper:
encrypted_text += alphabet[new_index]
else:
encrypted_text += alphabet[new_index].lower()
else:
encrypted_text += char
return encrypted_text
pass
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 67