April 2017
Beginner to intermediate
312 pages
7h 23m
English
Note the indentation in the for loop block:
for i in range(10, 1, -1): print("Count down no: ", i)
Python executes the block of code under the for loop statement. It is one of the features of the Python programming language. It executes any piece of code under the for loop as long as it has same level of indentation:
for i in range(0,10): #start of block print("Hello") #end of block
The indentation has the following two uses:
It is important to pay attention to indentation in Python as it directly affects how a piece of code is executed.
Read now
Unlock full access