This lesson is asking:
Now, instead of printing 'space!'
, use the addition assignment operator to add the space (currently stored in char
) to the current value of encrypted_text
.
I have already deleted the ‘space!’
But then it show the message:
You should use the +=
operator to add char
to the current value of encrypted_text
inside your new if
statement.
And I don’t get what to do, the instruction is not clear, can someone tell me step by step what should I do of can someone show me how the code is supposed to be.
I will put the code here below to show where I’m stuck:
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)