Introduction
In Python, a list can be defined as a dynamic array. In other words, it is a pack of elements, enclosed in square brackets ‘[]’, and the elements in it are separated by commas.
There are several methods with which we can operate on a list. One of them is the reverse() method, which we are going to discuss in this article.
Python List reverse() is an inbuilt list method with which we can reverse the elements of the list. By reverse, we mean to change the positions of elements. It does not use any extra space it just makes changes to the original list.
Syntax: name_of_list.reverse()
Parameters: No parameters are required.
Returns: It does not return anything, reverses the objects in the list.
The best way to understand the reverse() function in Python is to look at some examples
Examples of Python List reverse()
Code
Output
Code
Output
Code
Output
Error in reverse() method
When anything other than a list is used to reverse then it returns an attribute error.
Code
Output
Practical Applications
Code
Output
Code
Output
Examples
Code
Output
Code
Output
Code
Output
Code
Output