+ 1

How can i take 2*3 matrix as input?i have to make function of it?,

2nd Sep 2018, 5:46 AM
Syed Ahmed Abdullah
Syed Ahmed Abdullah - avatar
3 Answers
+ 15
input_matrix = [] while True: row = input() if row: input_matrix.append(row) else: break print(input_matrix) # this works here at SL code playground # but you must input a blank line at the end # or the while loop never reaches "break"
2nd Sep 2018, 6:29 AM
Eduardo Petry
Eduardo Petry - avatar
+ 3
I think you want to take the single elements of the matrix as input? m = [[input('0,0> '), input('0,1> '), input('0,2> ')], [input('1,0> '), input('1,1> '), input('1,2> ')]] print(m) # doesn't work in Sololearn, but in every console
2nd Sep 2018, 7:29 AM
Anna
Anna - avatar
+ 1
it shows invalid syntax for "]".
2nd Sep 2018, 6:19 AM
Syed Ahmed Abdullah
Syed Ahmed Abdullah - avatar