Exercice 60
Ecrire un algorithme Python permettant d'inverser l'ordre des éléments d'une liste en utilisant la méthode reverse().
Exemple si L = ['Java' , 'Python' , 'PHP' , 'C++'] , l'algorithme renvoie la liste: ['C++' , 'PHP' , 'Python' , 'Java']
Solution
|
1 2 3 4 5 6 7 8 9 10 11 |
#coding: utf-8 def reverseList(L): # inverser la la liste L L.reverse() return L # Exemple L = ['Java' , 'Python' , 'PHP' , 'C++'] print(reverseList(L)) # la sortie est: ['C++', 'PHP', 'Python', 'Java'] |
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 60: algorithme python qui détermine l'inverse d'une liste”