Advertisement
Fhernd

filtro-comprension-lista.py

Apr 2nd, 2018
2,363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. lista_numeros = [-11, 29, 2, -2, -5, 7, 13, 19, -1, 23]
  2.  
  3. lista_numeros_positivos = [n for n in lista_numeros if n > 0]
  4.  
  5. print(lista_numeros_positivos)
  6.  
  7. lista_numeros_negativos = [n for n in lista_numeros if n < 0]
  8.  
  9. print(lista_numeros_negativos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement