Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

Hi,

I’m currently working on step 37 of the “Scientific Computing with Python” module, specifically in the “Learn String Manipulation by Building a Cipher” section. The task requires me to:

Replace new_char with encrypted_text.
Modify the print() call to be print(‘char:’, char, ‘encrypted text:’, encrypted_text) inside the for loop. I am still getting the following error message:

You should turn your print() call into print(‘char:’, char, ‘encrypted text:’, encrypted_text) inside your for loo

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)   
    new_index = index + shift
    encrypted_text=alphabet[new_index]
    print('char:', char, 'encrypted_text:',encrypted_text)



 

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

Welcome to the forum @albagia94

You should turn your print() call into print('char:', char, 'encrypted text:', encrypted_text) inside your for loop.

Try replacing the underscore in the second string with a single space.

Happy coding

Thank you! It worked!

1 Like