The second example is a more explicit range class call. It clearly defines the starting point. In the same way, you can explicitly define the "step" of each iteration: range(0, 10, 2) ---> (0, 2, 4, 6, 8) (see help(range) in the python interpreter: shows: class range(object) | range([start,] stop[, step]) where [start,] and [, step] are optional. As you have shown, range (x) starts at 0 and defaults to default.
Starting with python 3, the range function is now the same as xrange (), since it iterates at every step, as opposed to creating a list.
source share