List objects support additional operations that allow in-place
modification of the object.
These operations would be supported by other mutable sequence types
(when added to the language) as well.
Strings and tuples are immutable sequence types and such objects cannot
be modified once created.
The following operations are defined on mutable sequence types (where
x is an arbitrary object):
s[i] = x
item i of s is replaced by x
s[i:j] = t
slice of s from i to j is replaced by t
same as s[i:j] = 
same as s[len(s):len(s)] = [x]
same as s[len(s):len(s)] = x
return number of i's for which s[i] == x
return smallest i such that s[i] == x
same as s[i:i] = [x]
if i >= 0
same as x = s[i]; del s[i]; return x
same as del s[s.index(x)]
reverses the items of s in place
sort the items of s in place
The C implementation of Python has historically accepted
multiple parameters and implicitly joined them into a tuple; this
no longer works in Python 2.0. Use of this misfeature has been
deprecated since Python 1.4.
Raises an exception when x is not a list object. The
extend() method is experimental and not supported by
mutable sequence types other than lists.
Raises ValueError when x is not found in
When a negative index is passed as the first parameter to
the insert() method, the new element is prepended to the
The pop() method is only supported by the list and
array types. The optional argument i defaults to -1,
so that by default the last item is removed and returned.
The sort() and reverse() methods modify the
list in place for economy of space when sorting or reversing a large
list. To remind you that they operate by side effect, they don't return
the sorted or reversed list.
The sort() method takes an optional argument
specifying a comparison function of two arguments (list items) which
should return a negative, zero or positive number depending on whether
the first argument is considered smaller than, equal to, or larger
than the second argument. Note that this slows the sorting process
down considerably; e.g. to sort a list in reverse order it is much
faster to use calls to the methods sort() and
reverse() than to use the built-in function
sort() with a comparison function that reverses the
ordering of the elements.