Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 List reverse() Method

Python3 List reverse() Method

Python3 Lists The Python3 list


Description

The reverse() function reverses the elements in a list.

Syntax

reverse() method syntax:


list.reverse()

Parameters

Return Value

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

Example

The following example shows how to use the reverse() function:


#!/usr/bin/python3

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

The output of the above example is:


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

Python3 Lists The Python3 list