Built-in Functions and Types
range()
Represent an arithmetic progression of integers without storing every term. The stop boundary is excluded; descending progressions require a negative step. Arguments must be integers or implement __index__(). A zero step raises ValueError. Ranges support indexing, slicing and membership but cannot be mutated. An empty progression is possible when the direction and boundaries disagree.
Formal Syntax & Structure
python syntaxpython
range(stop, /)range(start, stop, step=1, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| start | integer-like | First value; defaults to zero in the one-argument form. |
| stop | integer-like | Exclusive end boundary. |
| step | integer-like | Nonzero increment; defaults to one. |
Return Value
range
Reusable immutable sequence, not a one-shot iterator.
Working Example
Example Snippetpython
print(list(range(2, 12, 3)))print(list(range(5, 0, -2)))print(8 in range(2, 12, 3))