How many spaces to indent in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How many spaces to indent in Python?

All versions of code works: #1. With 4 spaces if True: print ("Spam") print ("Eggs") #2. With 2 spaces if True: print ("Spam") print ("Eggs") #3. Without spaces if True: print ("Spam"); print ("Eggs")

20th Nov 2016, 9:59 PM
Silvia
1 Answer
+ 2
You can use as many spaces as you want...just use the same amount of spaces for all of the code. The python documentation says to use 4 spaces thought...so I suggest you to stick with that
20th Nov 2016, 10:06 PM
Anitei Leonard
Anitei Leonard - avatar