Table of Contents
list
reference
x in s
x not in s
s + t the concatenation of s and t
s * n, n * s equivalent to adding s to itself n times
s[i]
s[i:j]
s[i:j:k]
s[i] = x
s[i:j] = t slice of s from i to j is replaced by the contents of the iterable t
del s[i:j] same as s[i:j] = []
s[i:j:k] = t the elements of s[i:j:k] are replaced by those of t
del s[i:j:k] removes the elements of s[i:j:k] from the list
s *= n updates s with its contents repeated n times
len(s)
min(s)
max(s)
L.append(object)
L.count(value) -> integer
L.extend(iterable)
L.index(value, [start, [stop]]) -> integer return first index of value; ValueError on failure
L.insert(index, object) insert object before index
L.pop([index]) -> item remove and return item at index (default last); IndexError on failure
L.remove(value) remove first occurrence of value; ValueError on failure
L.reverse() reverse *IN PLACE*
L.sort(cmp=None, key=None, reverse=False) stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1
List Comprehension discussion
Emit two or more items for each iteration in list comprehension howto
Set local variables in list comprehension howto
- Use nested list comprehension
[0, 0, 2, 1, 4, 4, 6, 9, 8, 16]
Get the last item from a list or an iterator howto