+ 4

How can I use list.reverse() in Python?

I've read that it can be used for switching elements' position in lists, but I don't know how it is used.

12th Mar 2017, 9:25 PM
Andrés Barrera
Andrés Barrera - avatar
2 Antworten
+ 2
Hello, please try this one: some_list = [1, 2, 5, 10] some_list.reverse() print(some_list) [10, 5, 2, 1]
12th Mar 2017, 10:45 PM
Stanislav Syarkevich
Stanislav Syarkevich - avatar
+ 2
numbers = [1, 2, 3, 4, 5] number.reverse() print (numbers)
3rd Oct 2017, 12:27 AM
Alex