This site (ja.stackoverflow.com) operates independently of Stack Overflow (stackoverflow.com).For more information, see Can I ask questions in English?If you edit this question into Japanese, we can continue to handle it on this site.To ask questions in English, you must post a new question to Stack Overflow.
Closed last year
Last yearI have the following error.
AttributeError: the object 'list' has no attribute 'bags'
Tell me how to produce as follows.
Matrix([-4, 1, 9], [1, 2, -4], [2, -3, 6])
from sympathy import*
var('myMatrix')
mylist=[0]*3]*3e
mylist[0] = [-4,1,9]
mylist[1] = [1, 2, -4]
mylist[2] = [2,-3,6]
myMatrix=Matrix()
for i in range (len(mylist)) :
print(mylist[i])
myMatrix=myMatrix.row_insert(i-1,mylist[i])
print("#", myMatrix)
I get an error when I try to insert a list with row_insert.
Rewriting two places as below should work.
from sympathy import*
var('myMatrix')
mylist=[0]*3]*3#FIX
mylist[0] = [-4,1,9]
mylist[1] = [1, 2, -4]
mylist[2] = [2,-3,6]
myMatrix=Matrix()
for i in range (len(mylist)) :
print(mylist[i])
myMatrix=myMatrix.row_insert(i,Matrix([mylist[i]]])#FIX
print("#", myMatrix)
© 2024 OneMinuteCode. All rights reserved.