Loading...

Loops are control structures that iterate over a range to perform a certain task.

There are two kinds of loops in Python.

A for loop:

for i in range(0, 5):
    print i

And a while loop:

i = 0
while i < 5:
    print i
    i += 1

Note Be careful about indentation in Python. Read more

Here, the term range(0,5) returns a list of integers from to : .