+ 5

How to take input in 2d array in python like matrix?

I'm not getting idea about how to take input and output the matrix in python.

4th Oct 2018, 4:18 AM
Ajay Agrawal
Ajay Agrawal - avatar
3 Answers
+ 2
if you need to apply matrix multipication or dot. import numpy as np size = (int(input("input "+['x', 'y'][i])) for i in range(2)) m = [] for i in range(size[0]): for j in range(size[1]): m.append(int(input('input x:{} y:{}'.format(i, j)))) mat = np.matrix(m) mat.size(size)
5th Oct 2018, 9:14 AM
Dudi
+ 4
rows = 3 [input().split() for i in range(rows)]
4th Oct 2018, 5:18 AM
davy hermans
davy hermans - avatar
+ 4
thankyou for help Jay Matthews davy hermans Dudi
4th Oct 2018, 9:54 AM
Ajay Agrawal
Ajay Agrawal - avatar