python - List comprehension returning values plus [None, None, None], why? -
this question exact duplicate of: understanding python 3 lists printing none value each element 1 answer im studying comprehensions. print(x) part (i think. prints value of x passes 'in' test) why returning list of none afterward? >>> g ['a', 'x', 'p'] >>> [print(x) x in g] x p [none, none, none] #whats this? you use list comprehension print items in list, , list printed. try assigning list variable instead. >>> g ['a', 'x', 'p'] >>> x = [print(x) x in g] x p # now list in x , isnt printed. list still there... >>> print(x) [none, none, none] >>> x [none, none, none]