When space matters and when not? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

When space matters and when not?

In "print( "Hi" )" space don't matters, but in ">>> print("hi)" that space after ">>>" makes an error in the code.

14th Aug 2019, 4:21 PM
Fake Elon
1 Answer
+ 4
In Python, space matters at the beginning of each line, because Python uses indentation for controlling the program flow. If a line of code is not in a block, it needs to be right at the left side, with no space. If it's in a block, it HAS TO be indented, but exactly like the other lines in the block. if 1>0: print(1) print(2) print(3) The last line is a mistake: It is in the block, but not in alignment with the other lines.
14th Aug 2019, 4:25 PM
HonFu
HonFu - avatar