Search code examples
pythonnested-lists

Print nested list as a matrix


i have a list which i need to print as a matrix! nestedList = [[1,2,3],[4,5,6],[7,8,9]]

   **i want the output to be**
     [1,2,3]
     [4,5,6]
     [7,8,9]

Solution

  • That will do a thing (although there is clearly no explanation why you need this)

    "[" + "\n".join(str(i) for i in [[1,2,3],[4,5,6],[7,8,9]]) + "]"