Python List append() Method

Python 列表Python List


Description

The append() method is used to add a new object to the end of the list.

Syntax

The syntax of the append() method is:

list.append(obj)

Parameters

  • obj -- The object to be added to the end of the list.

Return Value

This method has no return value, but it modifies the original list.

Example

The following example demonstrates how to use the append() function:

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc'];
aList.append( 2009 );
print "Updated List : ", aList;

The output of the above example is as follows:

Updated List :  [123, 'xyz', 'zara', 'abc', 2009]

Python 列表Python List

Other Extensions