There are multiple ways to take 2d array input in Python. Here I have mentioned the basic to take 2d array input:

n_rows= int(input("Number of rows:"))

n_columns = int(input("Number of columns:"))

#Define the matrix

matrix = [ ]

print("Enter the entries row-wise:")

#for user input

for i in range(n_rows): # A for loop for row entries

a =[ ]

for j in range(n_cols): # A for loop for column entries

a.append(int(input()))

matrix.append(a)

#To print the matrix

for i in range(n_rows):

for j in range(n_cols):

print(matrix[i][j], end = " ")

print( )

Output:

Enter the number of rows:2

Enter the number of columns:3

Enter the entries rowwise:

3

4

5

6

7

8

3 4 5

6 7 8

If you are interested to learn Python from Industry experts, you can sign up this Python Certification by Intellipaat.

You can watch this video on Python tutorial in Hindi by Intellipaat to learn the fundamentals of Python: