Error

Filling a matrix with values ​​from the keyboard

Let the program receive a two-dimensional array as input, in the form of n lines, each of which contains m numbers separated by spaces. How to count them? For example like this:

A=[] for i in range(n): A.append(list(map(int, input().split()))) # the list() method creates a list(array)   # from the set of data given in brackets

Or, without using complex nested function calls:

A=[] for i in range(n): row = input().split() # read a string with numbers, # split into elements by spaces (got array row) for i in range(len(row)): row[i] = int(row[i]) # each element of list row converted to a number A.append(row) # append array row to array A

Iterating over matrix elements

Each element of the matrix has two indices, so you need to use a nested loop to iterate over all the elements.
Usually a matrix is ​​iterated row by row: the outer loop iterates over the row indices, while the inner loop iterates over the column indices.
But if necessary, you can iterate over the matrix and the columns, then the cycles are reversed.