2.2. Whitespaces and indentation

2.2. Whitespaces and indentation

In Python whitespace is an important thing. We divide different identifiers using spaces.Whitespace in the beginning of the line is known as indentation, but if you give wrong indentation it will throw an error. Examples are given below:

>>> a = 12
>>>  a = 12
  File "<stdin>", line 1
      a = 12
          ^
          IndentationError: unexpected indent

Warning

There is an extra space in the beginning of the second line which is causing the error, so always look for the proper indentation.

You can even get into this indentation errors if you mix up tabs and spaces. Like if you use spaces and only use spaces for indentation, don't use tabs in that case. For you it may look same, but the code will give you error if you try to run it.