Print list of lists in separate lines

后端 未结 6 1853
生来不讨喜
生来不讨喜 2020-12-01 10:15

I have a list of lists:

a = [[1, 3, 4], [2, 5, 7]]

I want the output in the following format:

1 3 4
2 5 7
<
6条回答
  •  天命终不由人
    2020-12-01 10:24

    You can do this:

    >>> lst = [[1, 3, 4], [2, 5, 7]]
    >>> for sublst in lst:
    ...     for item in sublst:
    ...             print item,        # note the ending ','
    ...     print                      # print a newline
    ... 
    1 3 4
    2 5 7
    

提交回复
热议问题