On 2014-01-23 07:15, Ayushi Dalmia wrote: > I need to initialise a dictionary of dictionary with float values. > I do not know the size of the dictionary beforehand. How can we do > that in Python -- Either
d = {} or, if you want from collections import defaultdict d = defaultdict(float) print(d["Hello"]) If you really do want a dict-of-dict that defaults to floats, you can do d = defaultdict(lambda: defaultdict(float)) print(d[3141]["Hello"]) -tkc -- https://mail.python.org/mailman/listinfo/python-list