Proper indentation in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Proper indentation in python

What’s the proper way to make an indentation in python kicking tab or doing a space 3 times when I mix tabs and spaces it gives me a error so what’s the proper way spaces or tab ?

7th Oct 2022, 4:11 AM
Lz1234
5 Answers
+ 7
Lz1234 , the python style guide (pep 8) mentiones to use 4 spaces per indentstion level. the tab key can also be used if the editor can convert tab to spaces. playground on android devices support this. mixing (real) tabs and spaces is not allowed. for more information read: https://peps.python.org/pep-0008/#indentation
7th Oct 2022, 8:20 PM
Lothar
Lothar - avatar
+ 5
Lz1234 , please use the link that is provided in my post. scroll down a bit and you will find the information. ... Code Lay-out Indentation Use 4 spaces per indentation level. ...
9th Oct 2022, 4:54 PM
Lothar
Lothar - avatar
+ 1
Lothar So im understanding that spaces are the pefered way I thought is was 3 spaces are you sure about the 4
9th Oct 2022, 12:59 AM
Lz1234
+ 1
Lz1234 What did you see in the guide Lothar posted?
9th Oct 2022, 6:29 AM
Emerson Prado
Emerson Prado - avatar
0
It's better to use tabs. It's faster. In some editors, it is possible to adjust the tab stop value. You can do the same number of spaces. But then again, tabulation is faster
7th Oct 2022, 11:40 AM
Knight
Knight - avatar