Python and indentation


why was there an error when I tried to indent python and monty_python after my first variable monty? When am I expected to use whitespace?

Replace this line with your code. 
#Python is a computer language! This indentation is incorrect but why?


Python indentation is not about style, but about structure and code blocks. Your code is three statements seemingly belonging to the same block, as the interpreter sees it. The indentation is not expected.

We only ever user an indent if there is a specific block of code related to the header line, such as if, elif and else, while, for, def, etc. All of these keywords indicate a code block following. The indentation (preceded by a colon) is that block.

For this exercise, write everything against the left margin. The other topics will come up in due course.


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