print matrix in Phyton

Asked

Viewed 1,783 times

1

I would like to know how to print a matrix [[2,3], [4,6]]
for example, in the form of line below line without using import

  • print(' n'. Join(l for l in matriz))

2 answers

1

This will print formatted:

matriz = [[2, 3, 4], [5, 6, 7]]
for linha in matriz:
    for coluna in linha:
        print(coluna,end='  ')
    print('\n')

1

First way

matriz = ((2, 3), (4, 6))
for linha in matriz:
    print(linha)

The result of this will be:

(2, 3)
(4, 6)

Second way

matriz = ((2, 3), (4, 6))
for linha in matriz:
    for coluna in linha:
        print(coluna)

The result will be:

2
3
4
6
  • If the answer solved the problem don’t forget to mark it as your solution

Browser other questions tagged

You are not signed in. Login or sign up in order to post.