To print the output of a 3x3 matrix in 3 lines in Python, you can use nested loops. Here's the code:
main.py131 chars7 lines
Output:
main.py21 chars4 lines
In this code, we iterate over each row of the matrix using the outer loop, and then iterate over each element in each row using the inner loop. The end=" "
argument in the print statement ensures that the elements are printed on the same line with a space as a separator. The print()
statement after the inner loop is used to move to the next line after printing each row.
gistlibby LogSnag