Learn String Manipulation by Building a Cipher - Step 24

Tell us what’s happening:

They asked me to “give your for loop a body by adding a call to print(i)
Remember to indent loop body” I really can’t understand what’s wrong with my code, need help

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmopqrstuvwxyz'
for i in text:
print(i)
pass 

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 24

You didn’t indent the body. Follow the first example in the instructions.

Did’nt understand , could you please tell what exactly i have to do

The pass keyword was a placeholder for the code which will be filling out the body of the for loop. You can remove it now that you have added a print call there.

Correct indentation is syntactically vital in Python. If your indentation is incorrect, the code will not work properly or even crash. All code which is part of the for loop should be indented four spaces inside it. Ensure that your print call is properly indented.

Read the lesson, it’s all about indentation. Follow the example.

Step 24
The code to execute at each iteration — placed after the : — constitutes the body of the loop. This code must be indented.

It’s in the first sentence.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.