Python indentation

Hi there,

I find myself reading “Indentation error: unexpected indent” and similar. How can I confirm my lines are correctly situated so I can avoid these messages?

Are you saying that they appear correct or that you don’t know how something should be indented?

Certain statements have bodies of code belonging to them, such as a for-loop which has a body of code which is to be repeated. You’d indent that, and then move back to the previous indentation level to exit that body of code

That’s it. I know they should be indented but not how. It seems like only one space can make a difference, but I wonder if there is a way to know just by looking if things are correct or not.

everything that doesn’t cause python to tell you it’s not valid is correct
it’s up to you to make it mean the right thing
python doesn’t pay attention to how much you indent as long as it’s more than the previous level. the generally accepted style is to indent by 4 spaces per indentation level