In the previous lesson, you learned how to iterate or loop over a collection of data in the form of a list. That was great for your small list of names, but what if you want to generate a list of numbers? To do that, you can use the built-in range
function.
There are three ways you can call range()
:
range(stop)
takes one argument.range(start, stop)
takes two arguments.range(start, stop, step)
takes three arguments.
viktor471 on Dec. 24, 2021
About range. It returns range object that behaves like generator object