Exercice 86
Etant donné une list L, écrire un algorithme en python qui renvoie la liste des éléments entiers de L.
Exemple: si
|
1 |
L = ["Python3" , 91 , "Java2" , 95] |
, l'algorithme renvoie la liste
|
1 |
[91 , 95] |
Solution
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# coding: utf-8 def listInteger(L): # initialisation de la liste des entiers lInteger= [] for x in L: # on teste si l'élément x est un entier if type(x) == int : lInteger.append(x) return lInteger # Exemple L = ["Python3" , 91 , "Java2" , 95] print(listInteger(L)) # La sortie est: [91, 95] |
Younes Derfoufi
CRMEF OUJDA

![[App intégrée] 2025 Upgraded Vidéoprojecteur 1920 * 1080P FHD 4K Mini Projecteur Portable Dual Contrôle avec Souris Android TV WiFi 6 BT5.2 180° Rotation Compatible avec HDMI/TV Stick/USB](https://www.tresfacile.net/wp-content/uploads/2025/12/Videoprojecteur-1920-1080P-FHD-4K-Mini-Projecteur-Portable-Dual-Control-250x236.png)

1 thought on “Solution Exercice 86: algorithme python qui renvoie la liste des éléments entiers d'une liste”