Skip to content

How to reverse a list in Python?

>>> the_list = [1,2,3]
>>> reversed_list = the_list.reverse()
>>> list(reversed_list)


>>> the_list = [1,2,3]
>>> the_list[::-1]
See also  Python code snippet - How to get last element in numpy array?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.