On Sat, Feb 5, 2011 at 14:08, Lisa Fritz Barry Griffin <lisaochba...@gmail.com> wrote: > Hi there, > > How can I do this in a one liner: > > maxCountPerPhraseWordLength = {} > for i in range(1,MAX_PHRASES_LENGTH+1): > maxCountPerPhraseWordLength[i] = 0
maxCountPerPhraseWordLength = {0 for i in range(1,MAX_PHRASES_LENGTH+1)} But I suggest using a defaultdict: http://docs.python.org/dev/py3k/library/collections#defaultdict-objects Daniel -- http://mail.python.org/mailman/listinfo/python-list