Method Name
extend
Method Signature
extend(anotherlist_in)
Method Overview
The extend() method appends an existing list object as specified by the parameter anotherlist_in to the python list.
Parameters
anotherlist_in: An existing Python list object which is to be appended to the list object.
Exceptions
None
Example
# Example Python program that extends
# an existing list with the contents from another list
l1 = ["Philosopher's Stone", "Chamber of Secrets", "Prisoner of Azkaban"]
l2 = ["Goblet of Fire", "Order of the Phoenix", "Half-Blood Prince", "Deathly Hallows"]
l1.extend(l2)
print(l1)Output
["Philosopher's Stone", 'Chamber of Secrets', 'Prisoner of Azkaban', 'Goblet of Fire', 'Order of the Phoenix', 'Half-Blood Prince', 'Deathly Hallows']