Python 3 - List reverse() Method


Advertisements

Description

The reverse() method reverses objects of list in place.

Syntax

Following is the syntax for reverse() method −

list.reverse()

Parameters

NA

Return Value

This method does not return any value but reverse the given object from the list.

Example

The following example shows the usage of reverse() method.

#!/usr/bin/python3

list1 = ['physics', 'Biology', 'chemistry', 'maths']
list1.reverse()
print ("list now : ", list1)

Result

When we run above program, it produces the following result −

list now :  ['maths', 'chemistry', 'Biology', 'physics']
python_lists.htm
Advertisements