Is Python using tabs or spaces?

Rudrakshya Barman

Rudrakshya Barman

February 19, 2023
1 min read
Python code can use either tabs or spaces for indentation, but it's generally recommended to use 4 spaces for consistency and readability. The official Python Style Guide, also known as PEP 8, recommends using spaces over tabs for indentation. In fact, it explicitly states, "Spaces are the preferred indentation method."

It's worth noting that mixing tabs and spaces for indentation can cause problems and is generally discouraged. Many text editors and IDEs allow you to configure how tabs are displayed and converted to spaces, which can help ensure consistent indentation in your code.
Rudrakshya Barman

Written by Rudrakshya Barman

Software Consultant, Founder & CTO

More to read

Recent notes

Browse topics

Share this note