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
Acheter sur Très Facile !
-

Cryptographie En Python: Cours et exercices avec solutions. BTS - DUT - Licence SMI - MIP
€ 20,00 Acheter le livre -

TP-Link Archer T3U : Clé WiFi Puissante AC1300 Mbps
€ 15,00 Acheter le produit -

Apprendre l'intelligence artificielle avec Python : Recherche, optimisation, apprentissage
€ 32,00 Acheter le livre
1 thought on “Solution exercice 60: algorithme python qui détermine l'inverse d'une liste”