Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python The Challenge

For loop indentation

alt text

I am in the last print line, but for some reason it indents it as if I am still in the for loop. How do I know I am outside of the loops?

2 Answers

Try to go to the end of the line and then hit enter.

sometime workspaces behaves abnormally so I would suggest running your python locally, you can install the interpreter here https://www.python.org/downloads/ and VScode (editor) here https://code.visualstudio.com/

Will do that! Thanks a million!

Hi,

When you unindent your line you will be outside the loop that is right above it, generally you should have 4 spaces to have your line inside the loop. You can do this with a keyboard shortcut 'ctrl+[' for unindenting and 'ctrl+]' for indenting if you do not want to delete spaces manually and it also a great way to avoid errors.

Also, as a side note, you can post your code directly in your question's details instead of a screenshot by typing 3 backticks (`) then 'python' then your code and then another 3 backticks

{'''python

your code here

'''}

ignore the curly brackets above.

Hope this helps!

Thanks a lot Yahya for your reply and advice!

The thing is when I unindent and I press enter for a new line it still indents four or more spaces automatically as if I am still in the loop block. Do you have any idea why this happens?

I used the screenshot to show where the curser is indented in the last print line.