The challenge is:
Instead of assigning alphabet[new_index]
to encrypted_text
, assign the current value of encrypted_text
plus alphabet[new_index]
to this variable.
text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
encrypted_text = ‘’
for char in text.lower():
index = alphabet.find(char)
new_index = index + shift
encrypted_text = ‘’ + alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)
And this is the code that i wrote. I don’t quite understand what they mean by the current value of “encrypted_text”. I don’t understand what i am doing wrong.
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 35