Range() in python

 Range() function

In python range function is used to print the between values in python.

Syntax :

Range(start,stop,step)

Step has an default value of 1 the is the incremental value.

Example: range (2)  

Gives values 0,1

The given does includes the 2 


Range() in for loop

For elements in range(19):
(After 4 spaces )print(elements)

Above code prints numbers upto 0 to 18 one after another.

What is range(0,10,2)

The above code prints even numbers upto 8
That is 
0 -> start value
10 -> stop 
2 -> incremental value but the default value is 1

No comments: