Answers for "inverser une liste python"

1

inverser une liste python

l=[1,10,100,250,500]
l.reverse()
print(l)
#pour utiliser l'inverse de la liste sans l'inversée
l1=[1,2,3,4,5]
for i in reversed(l1):
    print(i)
#l1 reste inchangée 
print(l1) 
#output ------------------->

[500, 250, 100, 10, 1]
5
4
3
2
1
[1, 2, 3, 4, 5]
Posted by: Guest on July-17-2021
-1

comment faire pour retourner une liste python

list[1,2,3,4,5,6]
reverse(list)
print(list)
Posted by: Guest on July-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language