我正在根据用户输入制作一个矩阵,然后转置它,但是出现以下错误
'map' object is not subscriptable
我在理解map函数如何在后台工作时遇到问题。
请注意,我不想使用任何库,例如numpy。
row.append(input(
"Enter the first row of the matrix(3 integers space seperated)."))
row.append(input(
"Enter the second row of the matrix(3 integers space seperated)."))
row.append(input(
"Enter the third row of the matrix(3 integers space seperated)."))
matrix = [map(int, i.split()) for i in row]
t_matrix = [[matrix[j][i] for j in range(3)] for i in range(3)]
print(t_matrix)