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

2992 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Sort a given input of lowercase letters alphabetically


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


Write a simple Python program that asks a user to input their age and name and then return the text: "Hi my name is *NAME*, and I am *AGE* years old."


Ask the user for a number and output the smallest divisor, bigger than one, for the inputted number. Output "Prime" if the number is a prime number.


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