Python List reverse()

In this tutorial, we will see about Python List‘s reverse method.Python List reverse method is used to reverse the list.

Python List reverse example

You can simply call reverse method to reverse the list.
Let’s understand this with the help of simple example.

Output:

💻 Awesome Tech Resources:
  • Looking for ⚒️ tech jobs? Go to our job portal.
  • Looking for tech events? Go to tech events 🗓️ Calendar.️
listOfItems: [‘Clock’, ‘Bed’, ‘Fan’, ‘Table’] listOfItems in reversed order: [‘Table’, ‘Fan’, ‘Bed’, ‘Clock’]

As you can see here, list got reversed using reverse method.
There are other ways to reverse the list. You can use slicing to reverse a list.

Output:

listOfItems: [‘Clock’, ‘Bed’, ‘Fan’, ‘Table’] listOfItems in reversed order: [‘Table’, ‘Fan’, ‘Bed’, ‘Clock’]

If you just want to traverse in reverse order, you can use reversed function too.

Output:

Table
Fan
Bed
Clock

That’s all about Python List reverse method.

Related Posts

Leave a Reply

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

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.