Sep-19-2020, 03:41 AM
range
returns iterable object that produces sequence of numbers (from start to end). If you type help(list)
, you can see that list-constructur expects as its argument an iterable object. So, if you passed range
object to list
, list constructor would just unpack (traverse the iterable and build the list) content of the range object. However, if you type [range(9)]
, you put range
object directly into the list (without unpacking). Note, you can also unpack range as follows: [*range(9)]
.