range function

Range Function


The syntax of range() is as follows:

range (start,stop,[step])

Where,

start – refers to the initial value

stop – refers to the final value

step – refers to increment value, this is optional part.


Example : Examples for range()

range (1,30,1) will start the range of values from 1 and end at 29

range (2,30,2) will start the range of values from 2 and end at 28

range (30,3,-3) - will start the range of values from 30 and end at 6

range (20) will consider this value 20 as the end value(or upper limit) and starts the

range count from 0 to 19 (remember always range() will work till stop -1 value only)

Python : Range function Program List