I'm working on a polynomial organizer. I need to insert two items into the list of coefficients and powers, (a zero for the coefficient and the missing power) wherever needed.
print poly
poly=list(poly.split(','))
for i in range(0,13):
if int(poly[i*2+1])!=int(12-i):
poly=poly.insert((i*2+1),str(12-i))
poly=poly.insert((i*2+1),"0")
returns
0,12,0,11,0,10,0,9,0,8,-7,7,1,5,-1,4,1,3,-2,2,5,0
Traceback (most recent call last):
File "python", line 105, in <module>
File "python", line 97, in mypoly
AttributeError: 'NoneType' object has no attribute 'insert'
I'm confused because from what I've read on the insert function, it is made to work on lists, but here it seems not to. Please don't kill this question... I've been trying to figure it out on my own for a while now, and always run into this problem.
So I want it to look like this:
[0,12,0,11,0,10,0,9,0,8,-7,7,0,6,1,5,-1,4,1,3,-2,2,0,1,5,0]
Notice the 0,6
and 0,1
.