Python List reverse() Method
Advertisements
Description
The method reverse() 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/python aList = [123, 'xyz', 'zara', 'abc', 'xyz']; aList.reverse(); print "List : ", aList;
Let us compile and run the above program, this will produce the following result:
List : ['xyz', 'abc', 'zara', 'xyz', 123]