Python Syntax
Python uses indentation, the spaces at the start of a line, to show which lines belong together. Four spaces per level is the standard. Mixing up the indentation causes an IndentationError.
Statements usually end at the end of the line, so you do not need semicolons. A colon at the end of a line such as if, for or def starts an indented block.
Example
if 5 > 2:
print("Five is greater than two")
print("This line is in the same block")
print("This line is outside the block")Result
Five is greater than two This line is in the same block This line is outside the block
Exercise
Finish the line that starts an if block.
if 5 > 2 print("yes")
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.