Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created April 2, 2018 13:06
Show Gist options
  • Save Fhernd/faf96a4f574cfbcb01a77f43d52df13a to your computer and use it in GitHub Desktop.
Save Fhernd/faf96a4f574cfbcb01a77f43d52df13a to your computer and use it in GitHub Desktop.
Uso de la función filter para filtrar elementos de una lista. OrtizOL.
valores = [-3, 'Python', 7, -13, '17a', '3', 11]
def filtrar_numericos(valor):
try:
int(valor)
return True
except ValueError:
return False;
valores_filtrados = list(filter(filtrar_numericos, valores))
print(valores_filtrados)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment