Lesson 6-white spaces


#1

in lesson 6-whitespaces,why do we have to hit space bar 4 times on lines 2 and 3?


#2

I think space 4 times = a tab indent. Really, you don't have to indent 4 spaces. You could just indent one, but its easier to edit your code and keep it consistent if you always indent with four spaces or a tab.


#3

In Python, it is quite common to see 4 spaces being used for different programming constructs such as loops, if statements, functions etc ... You don't have to add 4 spaces, you can add 1 or even 5. The whole point of indentation is to make it easy to read your code. The 4 spaces has become standard and just something everyone has followed and lots of editors such as PyScripter follows.

Example:
if age >=18:
print("You can enter the club")
Else:
print("You are too young.")

Example:
if age >=18:
print("You can enter the club")
Else:
print("You are too young.")

The two examples above will work the same, irrespective of the spaces...

Have a look here:
https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces