logo

Python List Extend() Method


Show

Description

Python list method extend() appends the contents of seq to list.

Syntax

Following is the syntax for extend() method -

list.extend(seq)

Parameters

  • seq - This is the list of elements

Return Value

This method does not return any value but adds the content to the existing list.

Example

The following example shows the usage of extend() method.

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc', 123];
bList = [2009, 'manni'];
aList.extend(bList)
print "Extended List : ", aList

When we run the above program, it produces the following result -

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

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.