python - Index error on Polynomial array program -
I have this code which is receivestwo lists (considered in power order) though that I'm trying to multiply , I keep an index error and I do not understand why
def by (a, b): a.reverse () b.reverse () c = [] al = len (A) bl = len (b) for category i (al): for category J (b): k = a [i] * b [j] ii = i + jc [ii] + = k C.reverse () returns (c)
c [ii] + = k this line is an error Because the c [ii] list is last in the end.
You can not increase the size of a list by specifying the index listed outside the range; You have to change any code such as attach or expand , or create lists with the elements already present. c = [lane (a) + lane (b)) in range for [0]
Comments
Post a Comment