take matrix input in python code example
Example 1: how to get matrix element in the form of matrix in python
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
matrix = []
print("Enter the entries rowwise:")
for i in range(R):
a =[]
for j in range(C):
a.append(int(input()))
matrix.append(a)
for i in range(R):
for j in range(C):
print(matrix[i][j], end = " ")
print()
Example 2: how to input 2-d array in python
matrix = [input().split() for i in range(no_of_rows)]
matrix= [[input() for j in range(no_of_cols)] for i in range(no_of_rows)]