Skip to content
Built-in Functions

range()

Make a sequence of evenly spaced integers.

range(start, stop=None, step=1)

range() represents an immutable sequence of numbers commonly used for looping a specific number of times in for loops.

Accepts start, stop (exclusive), and step arguments.

Parameters

NameDescription
startThe first number, or the stop number when stop is omitted.
stopThe number to stop before.
stepHow much to add or subtract each time.

Returns

A range object.

Try it

Run it and change it
numbers = list(range(1, 6, 2))
print(numbers)

Worth knowing

  • Memory efficiency: A range object always takes the same small amount of memory regardless of the sequence size, computing items on demand.

Related entries