Monday, 12 August 2013

List comprehension returning values plus [None, None, None], why?

List comprehension returning values plus [None, None, None], why?

Im studying comprehensions. I get the print(x) part (i think. It prints
the value of x that passes the 'in' test) but why is it also returning a
list of None afterward?
>>> g
['a', 'x', 'p']
>>> [print(x) for x in g]
a
x
p
[None, None, None] #whats this?

No comments:

Post a Comment