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.
#!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc', 123]; bList = [2009, 'manni']; aList.extend(bList) print "Extended List : ", aList ;
Let us compile and run the above program, this will produce the following result:
Extended List : [123, 'xyz', 'zara', 'abc', 123, 2009, 'manni']