Javatpoint Logo
Javatpoint Logo

Python List reverse() Method

Python reverse() method reverses elements of the list. If the list is empty, it simply returns an empty list. After reversing the last index value of the list will be present at 0 index. The examples and method signature is given below.

Signature

Parameters

No parameter

Return

It returns None.

Let's see some examples of reverse() method to understand it's functionality.

Python List reverse() Method Example 1

Let's first see a simple example to reverse the list. It prints all the elements in reverse order.

Output:

['e', 'l', 'p', 'p', 'a']

Python List reverse() Method Example 2

It returns empty list if the list is the list is empty. See the example below.

Output:

[]

Python List reverse() Method Example 3

This example demonstrate that after reversing order of element does not change.

Output:

Both are equal

Next TopicPython Lists




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA