1. The list can contain elements of any data type, and the elements in a single list do not need to be all of the same type.
2. The append () method adds a new element to the tail of the list. Only one parameter is accepted.
3. The Extend () method accepts only one list as an argument and adds each element of the parameter to the original list.
Append () Usage Example:
>>> mylist = [1,2,0, ' abc ']
>>> MyList
[1, 2, 0, ' abc ']
>>> Mylist.append (4)
>>> MyList
[1, 2, 0, ' abc ', 4]
>>> mylist.append (' haha ')
>>> MyList
[1, 2, 0, ' abc ', 4, ' haha ']
>>>
Extend () Usage Example:
>>> MyList
[1, 2, 0, ' abc ', 4, ' haha ']
>>> mylist.extend ([' Lulu '])
>>> MyList
[1, 2, 0, ' abc ', 4, ' haha ', ' Lulu ']
>>> Mylist.extend ([AAA, ' Lalalala '])
Traceback (most recent):
File " ", line 1, in
Nameerror:name ' AAA ' is not defined
>>> mylist.extend ([' 123123 ', ' Lalalala '])
>>> MyList
[1, 2, 0, ' abc ', 4, ' haha ', ' Lulu ', ' 123123 ', ' Lalalala ']
>>> mylist.extend ([111111,222])
>>> MyList
[1, 2, 0, ' abc ', 4, ' haha ', ' Lulu ', ' 123123 ', ' Lalalala ', 111111, 222]
>>>
over!