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

Python List extend() method

Python List extend() method

Python Lists Python Lists


Description

The extend() function appends multiple values from another sequence to the end of a list at once (expanding the original list with a new list).

Syntax

extend() method syntax:



list.extend(seq)

Parameters

Return Value

This method has no return value, but adds the contents of the new list to the existing list.

Example

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



#!/usr/bin/python



aList = [123, 'xyz', 'zara', 'abc', 123];

bList = [2009, 'manni'];

aList.extend(bList)



print "Extended List : ", aList ;

The output of the above example is:



Extended List :  [123, 'xyz', 'zara', 'abc', 123, 2009, 'manni']

Python Lists Python Lists