Python and indentation


#1



https://www.codecademy.com/courses/introduction-to-python-6WeG3/4/1?curriculum_id=4f89dab3d788890003000096


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?
monty=True
    python=1.234
    monty_python=python**2


#2

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.


#3

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