Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

My loop runs i infinitely. I decleraed the variable before the loop and tried to call it.

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower():
    index = alphabet.find(char)    
    encrypted_text = index + shift
    new_char = alphabet[new_index]
    print('char:', char, 'encrypted text:', encrypted_text)

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.4 Safari/605.1.15

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

Do you get an error message?

Loop should not run infinitely, the page might be hung. Refresh and try it again. When I run your code I get a clear error message:

Traceback (most recent call last):
  File "main.py", line 9, in <module>
NameError: name 'new_index' is not defined