I am familiar with the difference between range() and xrange(). I noticed something weird with xrange():
>>> xrange(1,10,2)
xrange(1, 11, 2)
>>> xrange(1,10,4)
xrange(1, 13, 4)
Functionally, it is correct:
>>> for item in xrange(1,10,4):
... print item
...
1
5
9
>>>
However, as you can see, the stop value in the returned xrange object is the next higher value after the last legal value. Any reason why?
range() which now provides the same functionality in Python 3 as xrange in Python 2 behaves as expected:
>>> range(1,10,4)
range(1, 10, 4)
>>> range(1,10,2)
range(1, 10, 2)
>>>
xrange()is not the same asrange()in python 3. The latter is a new type. The end value is never included in eitherrange()orxrange(). Because of yourstepvalue, neither11nor10are included in the range output anyway.