0
I am trying to make a recursive function in Python that is not assigning me the correct results and when I try to change it it always happens stack overflow. This is my code:
def sublistas(lista):
i=0
if not isinstance(lista,list):
return 0
elif type(lista[i])==list:
return sublistas(lista[i])+(1)
else:
return 0
Someone might help me figure out what’s wrong here ?
Please explain what your code should do, not tell what is wrong if you don’t know what the purpose of the algorithm is. Tapping your eye up to assume it is a recursive counter of sublists within the original list, but it is assumption, edit your question and make it clearer.
– BrunoRB