xxxxxxxxxx
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)
xxxxxxxxxx
import numpy as np
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
print("Enter the entries in a single line (separated by space): ")
# User input of entries in a
# single line separated by space
entries = list(map(int, input().split()))
# For printing the matrix
matrix = np.array(entries).reshape(R, C)
print(matrix)
xxxxxxxxxx
row=int(input("Enter number of rows you want: "))
col=int(input("Enter number of columns you want: "))
mat=[]
for m in range(row):
a=[]
for n in range(col):
a.append(0)
mat.append(a)
for i in range(len(mat)):
for j in range(len(mat[0])):
mat[i][j]=int(input("Input element: "))
print("Your Matrix is :",mat)
xxxxxxxxxx
N=int(input())
mat=[]
for i in range(N):
row = []
row.append(list(map(int,input().split())))
mat.append(row)
print(mat)