To solve this you should use Python’s defaultdict. The first time you use a key that doesn’t exist, the argument to the defaultdict constructor is used to create a value (in this case, a list).
http://docs.python.org/library/collections.html#defaultdict-examples
from collections import defaultdict
d = defaultdict(list)
for i in range( 0, 10 ):
for j in range( 0, 100 ):
d[i].append( j )
You can also pass a function as the argument to defaultdict if you want to do anything more elaborate.