Range () method
The Range method, which creates a new list that contains a series of integers. The general form of calling the Range method is to provide a single value as the upper bound of the integer list. Zero is the starting value.
>>>range (8) [0,1,2,3,4,5,6,7]>>>range (2,8) [2,3,4,5,6,7]>>>range (2,15,2) [ 2,4,6,8,10,12,14]
x Range () method
The Xrange method also creates an integer list (which uses the same parameters), so it is very similar to the Range method. However, the Xrange method creates an integer in the list only when it is needed. For example, in Listing 6, when you try to print out the newly created xrange, no data is displayed except for the xrange name. The Xrange method is more appropriate when you need to iterate over a large number of integers because it does not create a large list, which consumes a lot of computer memory.
Range () and xrange () methods