How to take 2D array input in Python

Two-dimensional arrays are basically arrays within arrays. The position of a data item is accessed by using two indices. It is represented as a table of rows and columns of data items. As you know Python doesn’t have any array object, all we will be using lists.
In this article we will learn how to take 2d array input in python. If you are looking for “how to create 2d array in python“, this article will help you for the same.
n = int(input()) arr = [] for i in range(n): arr.append([j for j in input().split()]) print(arr)
Output:
2 2 3 4 2 4 5 [['2', '3', '4'], ['2', '4', '5']]
Subscribe
Login
Please login to comment
0 Discussion