Indentation, WhiteSpace, and Blank Lines

Python is unusual in that it requires indentation for lines of code. This will make more sense when we do if statements, while loops, and for loops.

For now, all you need to know is:

  • Do not put whitespace (spacing or tabs) in front of a line of code.
  • Python doesn't care about blank lines.

=== TASK ===

Copy the following code into a new Python file.

# This line is not indented properly. Fix this
  print("Indentation matters in Python")

# You will notice that we have blank lines
# Python doesn't care about these!

# There is extra whitespace inside the print statement 
# Python doesn't care about this
print("Hello World!"  )  

Run the code, and you will see an IndentationError exception on line 2.

This is due to the whitespace at the beginning of the line.

Fix this.

NOTE: You may also see that the code has a red squiggly line. This is highlighting an error!