What is the difference between xrange and range in Python?

The flippant answer is that range exists and xrange doesn’t :wink:

In Python 2, range returned a list and xrange returned an iterable that did not actually generate the full list when called. So range(2**23458) would run you out of memory, but xrange(2**23458) would return just fine and be useful.

Python 3 did away with range and renamed xrange to range, so it’s always safe to call range with as large a value as you like.