Base of difference | range() Method | xrange() Method |
Support | When we say about Python 3 xrange() is not supported and only range() function is sued to iterate in for loops. | xrange() function is used in Python 2 to iterate in for loops |
Returns type | range() method is mainly returns a list | xrange() returns a generator object as it doesnot really generate a static list at the run time |
Memory Used | range() method will take more memory as it needs to keeps the entire list of iterating numbers in memory | And on another hand xrange()will take less memory due to it keeps only one number at a time in memory. |