You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

13 lines
308 B

  1. # Exercice: remplacer le corps de la fonction
  2. # par une liste en compréhension
  3. def garde_les_positifs(nombres):
  4. résultat = []
  5. for nombre in nombres:
  6. if nombre > 0:
  7. résultat.append(nombre)
  8. return résultat
  9. nombres = [1, -3, 2, -5, 2, 4]
  10. print(garde_les_positifs(nombres))