On Oct 18, 2016 7:45 AM, "Sayth Renshaw" <flebber.c...@gmail.com> wrote: > > I was solving a problem to create a generator comprehension with 'Got ' and a number for each in range 10. > > This I did however I also get a list of None. I don't understand where none comes from. Can you please clarify? > > a = (print("Got {0}".format(num[0])) for num in enumerate(range(10))) > The comprehension collects the values of the 10 calls to print(). print() always returns None.
> # for item in a: > # print(item) > > b = list(a) > print(b) > > Output > Got 0 > Got 1 > Got 2 > Got 3 > Got 4 > Got 5 > Got 6 > Got 7 > Got 8 > Got 9 > [None, None, None, None, None, None, None, None, None, None] > => None > > Thanks > > Sayth > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list