Printing using list comprehension

You should restructure your loop to send arguments to print():

>>> numbers = [1,2,3]
>>> print(*(x for x in numbers), sep='\n')

Note that you don’t need the explicit generator. Just unpack the list itself:

>>> numbers = [1,2,3]
>>> print(*numbers, sep='\n')

Leave a Comment