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

2444 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between & and && operators?


Write a Python script to take a product name as input and then automatically google search reviews for it and open the top 3 search results in different tabs


How do I use format python code?


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


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences