Q:

Accessing list values in a defaultdict(list) type

I have a defaultdict(list) dictionary and im trying to access the stored values to perform some operations on them only i've never had to do this before so im not quite sure how to access them givin a list index and a key.
listdict = defaultdict(list)
listdict = {'Cake':['cheesecake','icecream cake','oreo-cheesecake']}

so e.g. say i wanted to use "Cake" key word to access "oreo-cheesecake" string at index 2 in the list.

A:

You are overwriting your defaultdict. It mostly works as a normal dict. We set elements:
listdict = defaultdict(list)
listdict['Cake'] = ['cheesecake','icecream cake','oreo-cheesecake']

And we recover them:
print listdict['Cake'][2]
    'oreo-cheesecake'

But you can do:
listdict['nonexistent'].append('stuff')

