Error:

Create empty list

l = []

Create list with elements

l = [1, 2, 3]

Get number of elements in the list

l = ['a', 'b', [1, 2]]
len(l) # 3

Check if list is empty

l1 = [1, 2]
l2 = []

if l1:
    print "l1 is not empty"

if not l2:
    print "l2 is empty"

Get element at certain index

l = ['a', 'b', 'c']
ch = l[2] # 'c'

Get first element of the list

l = range(1, 5) # [1, 2, 3, 4]
first = None
if l:
    first = l[0]

Get last element of the list

l = range(1, 5) # [1, 2, 3, 4]
first = None
if l:
    first = l[-1]

Join elements of the list with string

'/'.join(['a', 'b', 'c', 'd']) # 'a/b/c/d'

Remove element at index from the list

l = range

Remove particular value from the list

l = range(1, 5) # [1, 2, 3, 4]
del l[2]
l # [1, 2, 4]

Remove last element from the list

l = range(1, 5) # [1, 2, 3, 4]
l.pop()
l # [1, 2, 3]

Remove first element from the list

l = range(1, 5) # [1, 2, 3, 4]
l.pop(0)
l # [2, 3, 4]

Insert element at index

l = range(1, 5) # [1, 2, 3, 4]
l.insert(2, 'x')
l # [1, 2, 'x', 3, 4]

Add element to the end of the list

l = range(1, 5) # [1, 2, 3, 4]
l.append('x')
l # [1, 2, 3, 4, 'x']

Add element to the beginning of the list

l = range(1, 5) # [1, 2, 3, 4]
l.insert(0, 'x')
l # ['x', 1, 2, 3, 4]

Get sublist of the list

l = range(1, 10) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
sublist = l[3:5] # [4, 5]

Replace sublist of the arary with another list

l = range(1, 10) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
l[3:7] = ['a', 'b', 'c'] # [1, 2, 3, 'a', 'b', 'c', 8, 9]

Iterate over all elements of the list

l = range(1, 10) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
for n in l:
    print n

Get unique elements of the list

l = [1, 1, 2, 3, 4, 4, 5]
uniq_set = set(l) # set([1, 2, 3, 4, 5])
uniq_l = list(uniq_set) # [1, 2, 3, 4, 5]

Get difference between two lists

l1 = range(1, 6) # [1, 2, 3, 4, 5]
l2 = range(4, 9) # [4, 5, 6, 7, 8]
diff_set = set(l1) - set(l2)
diff_set # set([1, 2, 3])

Get intersection of two lists

l1 = range(1, 6) # [1, 2, 3, 4, 5]
l2 = range(4, 9) # [4, 5, 6, 7, 8]
int_set = set(l1) & set(l2)
int_set # set([4, 5])

Get union of two lists

l1 = range(1, 6) # [1, 2, 3, 4, 5]
l2 = range(4, 9) # [4, 5, 6, 7, 8]
union_set = set(l1) | set(l2)
union_set # set([1, 2, 3, 4, 5, 6, 7, 8])

Append one list to another

l1 = range(3) # [0, 1, 2]
l2 = range(5) # [0, 1, 2, 3, 4]
l1.extend(l2)
l1 # [0, 1, 2, 0, 1, 2, 3, 4]

Reverse the list

l1 = range(3) # [0, 1, 2]
l1.reverse()
l1 # [2, 1, 0]

Find first element of the list that passes test

from itertools import ifilter
l = range(1, 6) # [1, 2, 3, 4, 5]
mod3 = next(ifilter(lambda x: x%3 == 0, l), None) # 3
mod7 = next(ifilter(lambda x: x%7 == 0, l), None) # None

Find all elements of the list that pass test

l = range(1, 10) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
mod3 = filter(lambda x: x % 3 == 0, l) # [3, 6, 9]
mod2 = [x for x in l if x % 2 == 0] # [2, 4, 6, 8]

Sort the list numerically

l = ['5', '7', '1', '11', '17']
ordered = sorted(l, key = int)
ordered # ['1', '5', '7', '11', '17']

Sort the list lexically

l = ['5', '7', '1', '11', '17']
ordered = sorted(l) # ['1', '11', '17', '5', '7']
l.sort()
l # ['1', '11', '17', '5', '7']

Shuffle the list

from random import shuffle
l = range(1, 9)
shuffle(l) # e.g.: [4, 1, 2, 7, 6, 8, 5, 3] 

Map elements of the list

def square(x):
    return x**2

squares = map(square, range(1, 9))
squares # [1, 4, 9, 16, 25, 36, 49, 64]

Check if the list contains the element

l = range(1, 9)
5 in l # True
10 in l # False

Find maximum number in the list

l = [1, 4, 2, 6, 8]
m = max(l) # 8

Find minimum number in the list

l = [1, 4, 2, 6, 8]
m = min(l) # 1