• append
  • IndexError
  • list

Common scenario:

lst = []
# let's append one item
lst[0] = 'cbg'  # IndexError :(

The full error message is “IndexError: list assignment index out of range”.

The implicit (but wrong) assumption is either that the list will automatically expand to fit the new index, or that lst[len(lst)] = val is somehow special-cased.

The solution is to use list.append instead.