Learn String Manipulation by Building a Cipher - Step 35

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

Ah sorry for posting this. Found the solution to be “encrypted_text = encrypted_text + alphabet[new_index]”

3 Likes

Congratulations on figuring it out yourself!

We have blurred the solution (with [spoiler][/spoiler] tags) so that users who have not completed this challenge can read the discussion in this thread without giving away the solution.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.