This use of list() is only for printing, not needed to use range() in a loop. For cosmetic reasons in the examples below, the call of the range() function is inside a list() so the numbers will print out. This is perfect for generating the index numbers into, for example, a string.īelow are some more examples calling range(). Or put another way, range(n) returns a series of n numbers, starting with 0`. The most common form is range(n), for integer n, which returns a numeric series starting with 0 and extending up to but not including n, e.g. The range() function can be called in a few different ways. This is very useful, since the numbers can be used to index into collections such as string. The python range() function creates a collection of numbers on the fly, like