Python range() function
Python range() function
The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.
Syntax
range(stop)
or
range(start, stop[, step])
Parameter
start: It is an optional parameter that represents an integer number specifying at which position to start, and by default, its value is 0
stop: It is an optional value that represents an integer number specifying at which position to end.
step: It is an optional value that represents an integer number specifying the incrementation, and by default, its value is 1.
Return
This function returns a sequence of numbers, starting from 0.
Example 1
# Python Program describing # the range() function val = range(10) print("The value returned: ") for num in val: print(num)
Output
The value returned: 0 1 2 3 4 5 6 7 8 9