Spaces in Python | Sololearn: Learn to code for FREE!

+3

Spaces in Python

Is there a reason to put spaces in between calculations? for example 2+2 vs 2 + 2, because the output is the same. Besides that is there any rule for leaving a space?

3/21/2020 4:41:16 PM

Fran

3 Answers

New Answer

+8

No, it's just a matter of personal preference. I personally like to leave a space between operators so it's easier to read and distinguish them from each other. Other than that, there is no difference.

+3

It is easier to read. Keep it simple Keep it stupid

+2

Fran pep8 has something to say about that... https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements but let pep20 be your guide... https://www.python.org/dev/peps/pep-0020/ OR >>>import this 😜👍