Confusion of whitespace


For the 6th exercise, what is Whitespace used for, why is it used, and when do you have t use it?

the excerise

I expected a brief statement on why we have to white-space, when to do it, and how its effective..


from exercise 5: In Python, whitespace is used to structure code

python uses white whitespace (also called indention) to determine what is nested in an function:

def example():
  print "i am inside the function"
print "i am outside the function"

a for example a loop:

for i in "hello world":
   print i

as you can see, indention is often required after a colon (which marks the start of a function/loop and more)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.