Recursion error in test case #20 (ALL OTHERS PASSED)

I used a simulator to run a million tests but all of them are passing but test case 20 here is not .
Can anyone help?

def multiply_optimized(poly1, poly2):

if len(poly1) == 1 :
    product = [poly1[0]* poly2[i] for i in range(len(poly2)) ]
elif len(poly2)==1:
    product = [poly2[0]* poly1[i] for i in range(len(poly1)) ]
else:
    n = max(len(poly1),len(poly2))
    A, B = split(poly1, poly2)
    Y = multiply_optimized(add(A[0],A[1]), add(B[0],B[1]))
    U = multiply_optimized(A[0],B[0])
    Z = multiply_optimized(A[1],B[1])
    a=sub(sub(Y,U),Z)
    product = add(U,add(increase_exponent(a,n/2),increase_exponent(Z,len(poly1) + len(poly2) - 1 - len(Z))))

return (product if len(product)>0 else [])

These are the other functions used:

def add(poly1, poly2):
"""add two polynomials"""
result = [0] * max(len(poly1), len(poly2))
for i in range(len(result)):
    if i < len(poly1):
        result[i] += poly1[i]
    if i < len(poly2):
        result[i] += poly2[i]
return result

def sub(poly1, poly2):
"""Subtract two polynomials"""
result = [0] * max(len(poly1), len(poly2))
for i in range(len(result)):
    if i < len(poly1):
        result[i] += poly1[i]
    if i < len(poly2):
        result[i] -= poly2[i]
return result

def split(poly1, poly2):
"""Split each polynomial into two smaller polynomials"""
mid = max(len(poly1), len(poly2)) // 2
return  (poly1[:mid], poly1[mid:]), (poly2[:mid], poly2[mid:])

def increase_exponent(poly, n):
"""Multiply poly1 by x^n"""
return [0] * int(n) + poly

What is test case 20?

Sorry bro ,if i would have known i would have already found the answer lol .

I don’t know why it is giving a syntax error. If I run the same command separately it is working as it should. Anyone?

The error occurs when your inputs are empty lists.