Advertisement
Fhernd

uso-filter.py

Apr 2nd, 2018
2,328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. valores = [-3, 'Python', 7, -13, '17a', '3', 11]
  2.  
  3. def filtrar_numericos(valor):
  4.     try:
  5.         int(valor)
  6.         return True
  7.     except ValueError:
  8.         return False;
  9.        
  10.  
  11. valores_filtrados = list(filter(filtrar_numericos, valores))
  12.  
  13. print(valores_filtrados)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement