Oct-10-2019, 06:56 PM
(Oct-10-2019, 06:41 PM)buran Wrote: it's not an error.
(a[x] for x in range(6))
is generator expression that returns iterator. when you pass it as argument to function like print() you can omit the brackets to same effect.
In the first example you uselist()
to convert the same generator to alist
So in the first example it prints out the list, and in the second example it prints out what it is--which is a generator object (with iterating rule stored in memory address 0x030A8BB0, maybe?)?