Range
From Python official document:
class range(stop)
class range(start, stop[, step])
Rather than being a function, range is actually an immutable sequence type, as documented in Ranges and Sequence Types >— list, tuple, range.
Range is a little bit different than all other built-in functions. It’s essential a data type that’s built-in in Python. More specifically, it shares the same feature of list and tuple - it’s sequential. Let’s introduce some features and usage of range.
Start is inclusive and stop is exclusive
1
2for i in range(1, 3, 1):
print(i)This will print:
1
21
2