2
我想创建一个程序,乘以用户给出的两个矩阵。我希望用户输入第一个矩阵的行,然后我想将每一行保存在字典中,其中字典键是行的编号。然而,当我做的raw_input询问用户ith
行,我得到的错误:在Python中乘以矩阵,在raw_input的错误
TypeError: cannot concatenate 'str' and 'int' objects
这是我的代码:
print "this program computes the product of two square matrices with real entries"
n = raw_input("Enter number of columns=Number of rows")
rowsofmatrix1={}
columnsofmatrix2={}
for i in range (1,n+1):
rowsofmatrix1[i]=raw_input("Enter row number"+str(i)+"of the first matrix as a list")
for j in range (1,n+1):
columnsofmatrix2[j]=raw_input("Enter column number"+str(j)+"of the second matrix as a list")
print rowsofmatrix1
哦,我还没有意识到......我想我只是把输入,而不是raw_input。谢谢 – Diego