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

Python List append() method

Python List append() method

Python Lists Python Lists


Description

The append() method adds a new object to the end of a list.

Syntax

append() method syntax:



list.append(obj)

Parameters

Return Value

This method returns nothing, but modifies the original list.

Example

The following example shows 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:



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

Python Lists Python Lists