I have the following code but Python keeps saying "local variable 'a' referenced before assignment"
def inter(X,Y):
if pertenece(cabeza(X),Y):
a = lista(cabeza(X),inter(cola(X),Y))
elif vacia(cola(X)): return a
else: inter(cola(X),Y)
I have no idea why I'm getting this error since I have defined 'a' before referencing it. Please help.
The functions 'pertenece', 'cabeza', 'cola', 'vacia' and 'lista' where all previously defined and have no issue.
return awill only happen ifpertenece(cabeza(X),Y)is False, butawill only be set ifpertenece(cabeza(X),Y)is True. What do you wantato be whenpertenece(cabeza(X),Y)is False?if.