Printing using list comprehension

后端 未结 10 1745
一生所求
一生所求 2020-12-03 10:58

From my Python console

>>> numbers = [1,2,3]
>>> [print(x) for x in numbers]
1
2
3
[None, None, None]

Why does this print

10条回答
  •  孤街浪徒
    2020-12-03 11:47

    An ugly way of doing this is _=[print(i) for i in somelist] It does work but is not encouraged:)

提交回复
热议问题