Guys I've got a python question? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Guys I've got a python question?

I figured it out that in python, spaces between items in print command don't affect the result, is this true? And can we do this anywhere in python? For example: Print(4*5) Print( 4 * 5 )

11th Jun 2023, 11:28 AM
mohammad ali Sheikh
mohammad ali Sheikh - avatar
8 Answers
+ 6
mohammad ali Sheikh In most statements of most languages, spaces only affect string values - because that's the only place where they have a meaning
11th Jun 2023, 12:10 PM
Emerson Prado
Emerson Prado - avatar
+ 10
You can check it yourself in Python editor for example here in Sololearn Playground. Please try to do that and than ask again if you have still a problem. How about a python course.
11th Jun 2023, 11:33 AM
JaScript
JaScript - avatar
+ 8
mohammad ali Sheikh , most of the cases when and how using spaces in python code are explained in the python style guide pep-0008: https://peps.python.org/pep-0008/#code-lay-out
11th Jun 2023, 12:37 PM
Lothar
Lothar - avatar
+ 7
mohammad ali Sheikh did you try as I recommended? Here in this code example can you see how is the answer: https://code.sololearn.com/cBL9Kj0oB4nQ/?ref=app
11th Jun 2023, 4:29 PM
JaScript
JaScript - avatar
+ 2
Yes, ofcourse my friend, altough my programming knoledge is not enaugh but I tried some in Sololearn playground and that made me realize it's not so important to have empty spaces between components when we're coding in python.
12th Jun 2023, 2:57 PM
mohammad ali Sheikh
mohammad ali Sheikh - avatar
+ 2
Indentation is the one place where consistency in spaces is important in Python
13th Jun 2023, 9:47 AM
Bob_Li
Bob_Li - avatar
+ 1
I checked it and because of this I'm asking here cause in some cases I think it would be a problem.
11th Jun 2023, 11:59 AM
mohammad ali Sheikh
mohammad ali Sheikh - avatar
+ 1
Tnk u both Emerson Prado and Lothar
11th Jun 2023, 1:10 PM
mohammad ali Sheikh
mohammad ali Sheikh - avatar