Python3 List reverse() Method

Python3 列表Python3 List


Description

The reverse() function is used to reverse the elements in a list.

Syntax

The syntax of the reverse() method is as follows:

list.reverse()

Parameters

  • NA。

Return Value

This method has no return value, but it reverses the order of the list elements.

Examples

The following example demonstrates the usage of the reverse() function:

#!/usr/bin/python3

list1 = ['Google', 'Example', 'Taobao', 'Baidu']
list1.reverse()
print ("列表反转后: ", list1)

The output of the above example is as follows:

列表反转后:  ['Baidu', 'Taobao', 'Example', 'Google']

Python3 列表Python3 List

Other Extensions