The Range Function¶
You can use the
range function to create a list of numbers. If the
range function is passed just one value it will return a list of all the numbers from 0 to one less than that number.
If two values are passed as input to the
range function then it will return a list of values that includes the first value, but ends at one less than the second value. It is inclusive of the first value and exclusive of the second value.
Let’s rewrite the program that calculates the product using the
range function to generate the list of numbers as shown below.