If you want to read 2D arrays in Python, this is the easiest way to do it:
# Input the dimensions
rows = int(input("Enter number of rows: "))
array_2d = []
# Accept each row
for _ in range(rows):
row = list(map(int, input("Enter elements of the row, separated by spaces: ").split()))
array_2d.append(row)
# Print the 2D array
print("The 2D array is:")
for row in array_2d:
print(row)
Input Rows: Number of rows you need
Input Elements: Each row elements separated by space.
Store and Print: The elements will be stored in a list that is printed as 2D array. It is pretty straightforward and should help you just fine. Feel free to hear from you again if you have more questions!