fork download
  1. def count(lista, valor, i=0):
  2. if i >= len(lista):
  3. return 0
  4. c = 1 if lista[i] == valor else 0
  5. return c + count(lista, valor, i + 1)
  6.  
  7. # lista com 1000 elementos
  8. itens = list(range(1000))
  9. print(count(itens, 30))
Runtime error #stdin #stdout #stderr 0.12s 24416KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 9, in <module>
  File "./prog.py", line 5, in count
  File "./prog.py", line 5, in count
  File "./prog.py", line 5, in count
  [Previous line repeated 995 more times]
  File "./prog.py", line 2, in count
RecursionError: maximum recursion depth exceeded while calling a Python object