Home >>Python Built-in Functions >Python range() Function
Python range() function is used to return a sequence of numbers starting from 0 by default and increments by 1, and ends at any fixed given number.
Syntax:range(start, stop, step)
Parameter | Description |
---|---|
start | This is an optional parameter. It defines an integer number specifying at which position to start. |
stop | This is a required parameter. It defines an integer number specifying at which position to end. |
step | This is an optional parameter. It defines an integer number specifying the incrementation. |
x = range(10)
for n in x:
print(n)
x = range(2, 20, 2)
for n in x:
print(n)