I got to this point in the process where and I didn’t understand what the assignment was asking me to do. I only got it right because I copied what was in other threads but I don’t understand why its correct.
Why is the “encrypted_text += alphabet [new_index]” correct?:
for char in text.lower():
index = alphabet.find(char)
new_index = index + shift
encrypted_text = encrypted_text + alphabet[new_index]
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)
Instructions say
Use the
+=
operator to add a value and assign it at the same time to encrypted_text
But it doesn’t specify what value to add so why is alphabet[new_index] correct?
I initially tried
encrypted_text + encrypted_text + alphabet[new_index]
encrypted_text += encrypted_text
What makes this wrong ?