Basic_multiply not working for me. Does not give the product of the two polynomials

Why don’t I get the answer? What is wrong here. Appreciate help

def multiply_basic(poly1, poly2):

#poly1 = [2, 0, 5, 7]
#poly2 = [3, 4, 2]

len_poly1 = len(poly1)
len_poly2 = len(poly2)
multiply_basic = []
multiply_basic_len = len_poly1 + len_poly2 - 1
for i in range(multiply_basic_len):

for i in range(len_poly1):
    for j in range(len_poly2):
        multiply_basic[i+j] += poly1[i] * poly2[j]

multiply_basic([2, 0, 5, 7], [3, 4, 2])


You don’t get the answer… because you don’t return anything.

Just return the result and it should work.

PS: the return in for ... else won’t work, because that’s not how it’s supposed to be used.
Also no idea why you print(multiply_basic). That won’t work as well.

Thanks, Sebgolos.
When I execute the multiply_basic code, I get the following output

<function multiply_basic at 0x7f67dc46d940>

What does it mean and how to fix it? Thanks.

Won’t work because you aren’t calling the function.

You’re print the function, not the result of it. You need to call it with parentheses.

`multiply_basic_len = (len_poly1 + len_poly2) - 1 since output length was defined as (m+n)-1

for i in range(multiply_basic_len):
multiply_basic.append(0). ------what is the (0) that you want to add to the list?

multiply_basic([2, 0, 5, 7], [3, 4, 2])--------unquote poly1 and poly2 variables and use it for this line since you assigned the lists to these variables.

return. ----what are your returning?

multiply_basic[i+j] ------this will give an error…maybe you’re trying to append the product to the list?