Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Advanced Uses of range()

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.

Comments & Discussion

Become a Member to join the conversation.