Dictionary with Lists

John Nagle nagle at animats.com
Sun Oct 4 00:25:15 EDT 2009


Shaun wrote:
> Hi,
> 
> I'm trying to create a dictionary with lists as the value for each
> key.  I was looking for the most elegant way of doing it... 

    Try using a tuple, instead of a list, for each key.  Tuples
are immutable, so there's no issue about a key changing while
being used in a dictionary.

				John Nagle



More information about the Python-list mailing list