def inverter(lista): if len(lista) <= 1: # lista vazia ou com um elemento, retorna ela mesma return lista return lista[-1:] + inverter(lista[:-1]) # inverter lista com 3000 números lista = inverter(list(range(3000)))
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "./prog.py", line 7, in <module> File "./prog.py", line 4, in inverter File "./prog.py", line 4, in inverter File "./prog.py", line 4, in inverter [Previous line repeated 995 more times] File "./prog.py", line 2, in inverter RecursionError: maximum recursion depth exceeded while calling a Python object