Here's one option:
n = int(input("Enter the number of rows in a matrix: "))
a = [[0] * n for i in range(n)]
for i in range(n):
for j in range(n):
a[i][j] = int(input())
for row in a:
print(' '.join([str(elem) for elem in row]))
example: If IIf you use pandas, and make a dataframe... if you enter 4 for the number of rows, then enterand the numbernumbers 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, I will get the output:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Or, if you use pandas, and make a dataframe, your output would look nicer... the script below
If you again type in 4 for number of rows, and enter the numbers 1,2,3,4...16..will produce the following output. you'll get something that looks like this
Another option... using numpy... and the same values from the first option...
Using the same examples as before, your output would look like this:...would produce
