Home

Published

- 1 min read

how to Take Matrix input from user in Python

img of how to Take Matrix input from user in Python

The solution for this is noted below

how to Take Matrix input from user in Python

Solution

   matrix = []
n = int(input("Enter the number of row = "))
for i in range(n):
    row = []
    print("Enter the all values of -", (i+1), "no. row with enter", end='')
    for j in range(n):
        row.append(int(input()))
    matrix.append(row)
print(matrix)

Try other methods by searching on the site. That is if this doesn’t work