Python List extend() method
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
- seq -- the list of elements.
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