I wonder what is the difference between the range() and the xrange() functions in python. I have seen them used equally many times.
1 Answer
In Python 2.X range() creates a list. You can assign it to a variable. But xrange() creates an object that is used for iteration. range() consumes memory for each of its elements while xrange() doesn't have elements. I've read that xrange is better to conserve memory.
They discuss this more on What is the difference between range and xrange functions in Python 2.X?
1 Comment
EJoshuaS - Stand with Ukraine
You shouldn't answer questions that have been answered repeatedly. Please see How to Answer.