Is Python using tabs or spaces?

Published on: February 19, 2023

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.