Python For Loop using Range(N) Function


 The Python for loop is used to iterate over an element of sequence or data structure ( List, Tuple, String, Dictionary).

Classification of for loop using different type:-

1] Using Range(N) Function

Syntax-

range(start, stop, step size)

Start and Step size is optional.

By default, Start is 0 and Step size is 1 if not provided

 

If we use range(n), where n is an integer, then it will print an integer from 0 to n-1.

For example-

Using range(7), it will print an integer from 0 to 6

Program
# Using range(n) will print  integer from 0 to n-1 for a in range(7): print(a)
Input
Output