Indentation & Commenting

Learn to Code Today!

Learn 10x faster: coding, no-code and data skills. Join millions of users mastering new tech skills and accelerating their career with Enki.
Get started

This is part of “An intro to Python” series of posts, with content from the Enki app. If you stumbled upon this, you can start from the beginning.

Python is one of the very few programming languages that relies on the use of indentation (tabs) to work.

Usually, one indentation has four spaces in Python.

For example:

The above example returns:

If we were to rewrite the above snippet as:

The output will be:

The indentation determines whether the last call to print belongs to the else statement or whether it should be called separately from the if statement.

As a side note, indentation doesn’t matter for commented out lines. To comment out lines of code in Python, just use the hash symbol, #. For example:

About Enki

  • Fully personalized online up-skilling
  • Unlimited AI coaching
  • Designed by Silicon Valley experts

More articles

Meet your AI-enabled coach

Professional athletes have a coach for every aspect of their performance. Why can’t you for your work? Enki’s AI-powered coaching on-demand - combined with state of the art, structured learning content - makes this a reality.
1
1:1 AI Coaching
How do I remove duplicate emails?
Convert the list to a set and back to a list. Sets automatically remove duplicates.
2
Personalized Exercises
3
Interactive practice

Unlock full access to all skills on Enki with a 7-day free trial

Get started