Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created July 10, 2017 01:24
Show Gist options
  • Save marcoscastro/7b88551c048663271b45357a486cbf41 to your computer and use it in GitHub Desktop.
Save marcoscastro/7b88551c048663271b45357a486cbf41 to your computer and use it in GitHub Desktop.
Encontra ímpares com recursão em Python
def encontra_impares(lista):
if len(lista) == 0:
return []
e = lista.pop(0)
if e % 2 != 0:
return [e] + encontra_impares(lista)
return encontra_impares(lista)
print(encontra_impares([1,7,10,12,16,21,3,9,11]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment