Custom Search

Wednesday, November 3, 2010

python List extend() method

List extend() method

>>> l = [1]
>>>
>>> n = {'a':2,'b':3} <--------dict
>>>
>>> l.extend(n)
>>> l
[1, 'a', 'b'] <------- Note: taken only keys
>>> n = (8,9) <--------Tuple
>>> l.extend(n)
>>> l
[1, 'a', 'b', 8, 9]
>>>

No comments:

Post a Comment