What is the difference between using range() and a list of values?

The main differences between the two boil down to the difference between greedy and lazy evaluation. With a list, each indexed object takes up some space in memory. Range, however, calculates the next value on the fly, meaning only one object is stored in memory each time. However, this means range has to calculate each successive value, slowing down the processing speed.

LS
Answered by Luke S. Python tutor

3417 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Create a program that takes in two numbers and returns the highest of the two


Print "Hello World!" ten times without typing (or pasting) the print function more than once


Describe both For-loops and While-loops and explain how you can simulate the effect of a for loop with a while loop with an example.


Explain how you would write a python program that takes a rectangle and a point in a 2D space as command-line arguments and checks if they intersect.


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2026 by IXL Learning