Print a nested list line by line - Python

后端 未结 7 1532
-上瘾入骨i
-上瘾入骨i 2020-12-15 12:51

A = [[1, 2, 3], [2, 3, 4], [4, 5, 6]]

I am trying my best to print A of the form:

1 2 3
2 3 4
4 5 6

That

相关标签:
7条回答
  • 2020-12-15 13:41

    The same question was answered by Jim Fasarakis Hilliard in Print list of lists in separate lines.

    In Python 3.x we can use:

    A = [[1, 2, 3], [2, 3, 4], [4, 5, 6]]
    
    for i in A:
            print(*i)
    

    And the corresponding output is:

    1 2 3
    2 3 4
    4 5 6
    
    0 讨论(0)
提交回复
热议问题