Answers for "input a matrix in python"

0

Take Matrix input from user in Python

# Taking one row at a time with space-separated values.
# And converting each of them to using map and int function.

matrix = []
for i in range(row):
   col = list(map(int, input().split()))
   matrix.append(col)
print(matrix)

'''
Input :
1 2
3 4
Output :
[[1, 2], [3, 4]]
'''
Posted by: Guest on September-30-2021

Python Answers by Framework

Browse Popular Code Answers by Language