1
n = int(input())
mat = []
for i in range(n):
    row = map(int, input().split())
    mat.append(row)

print(mat)

when i run this code i get the following o/p

[map object at 0x7f30e08ccba8, map object at 0x7f30df3a3438, map object at 0x7f30df3a3518]

1 Answers1

4

The map object in 3.6 returns an iterator. You need to iterate all its values either by printing each single item, or simply wrapping it into a list( map(...., ...)) statement:

n = int(input())
mat = []
for i in range(n):
    row = list ( map(int, input().split()) ) # iterate all the values immediately
    mat.append(row)

print(mat)

For python 2.x the map command produces a list directly.

See https://docs.python.org/3/library/functions.html#map

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69