How to make a python program for multiplying elements of two lists?
Question: I want to make a python program which inputs two lists of numbers from user,
and outputs a list which satisfies some specific conditions. If I input a list
`[1,2,3]`, this means the polynomial that it represents is: `3x^2+2x+1`. Or,
in other words I have to multiply two polynomials.

For example, `L1=[1,2,3,1]` and `L2=[1,2]` then output list (L3) should be
`[1,4,7,7,2]`.

I tried to make a code which later turned out to be trash.

    
    
        L1=list(input("Enter the first list : "))
        L2=list(input("Enter the second list : "))
        L3=[]
        a=L1
        b=L2
    
        def multiply(L1,L2,a,b,L3,k,i,x):
            if k<=min(len(a),len(b)):
                if k-i==0:
                    x=x+L1.pop(i)*L2.pop(k-i)
                    return multiply(a,b,a,b,L3,k,i+1,x)
                elif k-i>0:
                    x=x+L1.pop(i)*L2.pop(k-i)+L2.pop(i)*L1.pop(k-i)
                    return multiply(a,b,a,b,L3,k,i+1,x)
                else:
                    L3.append(x)
                    return multiply(a,b,a,b,L3,k+1,0,0)
            else:
                return L3
    
        print multiply(L1,L2,a,b,L3,0,0,0)
    

Any assistance is greatly appreciated.


Answer: Two mistakes: first, pop() actually removes items from the list, which is
probably not what you want (there are only three lists in the whole program).
Then "if k <= ..." should probably be "if k < ..." because indices count from
0. With these two fixes the problem still outputs nonsense. I'll leave you the
task of figuring it out: try to replace the last line with

    
    
    import pdb; pdb.run("multiply(L1,L2,a,b,L3,0,0,0)")
    

then go step by step until something is wrong (`s` to do a step, `p VARNAME`
to print a variable).

