So far, you’ve seen how you can use the
range function to generate a list of integers. It might appear that using
range() in a
for loop is equivalent to using a list of incrementing or decrementing values, but that’s not the case. There are some important similarities and differences.
range() is its own class in Python:
>>> type(range(3)) <class 'range'>
range isn’t a list, but it dynamically manages a list in memory.