Python List extend() Method
Advertisements
Description
The 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 add the content to existing list.
Example
The following example shows the usage of extend() method.
Live Demo#!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc', 123]; bList = [2009, 'manni']; aList.extend(bList) print "Extended List : ", aList
When we run above program, it produces following result −
Extended List : [123, 'xyz', 'zara', 'abc', 123, 2009, 'manni']
python_lists.htm
Advertisements