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.
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.
['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.
Python List reverse() Method Example 3
This example demonstrate that after reversing order of element does not change.
Both are equal
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week