Created
July 10, 2017 01:24
-
-
Save marcoscastro/7b88551c048663271b45357a486cbf41 to your computer and use it in GitHub Desktop.
Encontra ímpares com recursão em Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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