Step 42 in scientific computing with python

Hi guys i am stuck on the step 42 I filled all what prompted :" 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 . my answer was as bellow:

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
     if char == ' ':
          char += new_index   
     index = alphabet.find(char)
     new_index = index + shift
     encypted_text += new_index
     print('char:', char, 'encrypted text:', encrypted_text)

Hello Ibrahim91!

You are currently adding new_index to char.
But the question wants you to add char to encrypted_text.

The encrypted_text variable holds the current encrypted text, and we want to add the space (inside char) behind it. You were close with the right logic, just have to adjust the variables!

1 Like

Thank you for your help, that made it clear to me