range() function in python


range() function in python

A range() function generates the sequence of numbers.
A range() function , by default starting from zero, to end with specified number
In range we can defined the start, stop and step_size  

 

Syntax range (start,stop,step_size) Example print(range(5)) # Return range(0,5) print(list(range(5))) # Return list [0,1,2,3,4] 5 is not included in list # we can define the start print(list(range(2,5))) # Return list [2,3,4] 5 is not included in list # we can define step size, it print the add + step size number value item print print(list(range(0,5,2))) # Return even number position item in list,                                                               [0,2,4]

Post a Comment (0)
Previous Post Next Post