Python range() method is a built-in method. It is used to create an immutable sequence of numbers. It returns an object of sequence that behaves like list but it is not. The object belongs to the range class.
Parameter | Description |
---|---|
Start | (Optional) It is starting value of the range. Its default value is 0. |
Stop | (Required) It is end value of the range. |
Step | (Optional) It is step value of the range. Its default value is 1. |
It returns an object of range class.
Let’s first understand, how to create a range and what type of object it returns?
Range elements can be accessed using indices. See the example.