![]() |
|
|
+ Search |
![]()
|
Jul 5th, 2000 09:59
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 54, Guido van Rossum
"""
Packages: basic_datatypes.dictionaries
"""
"""
> Well -- there is Guido van Rossum's variant:
Here's the correct version:
"""
def invert(table):
index = {} # empty dictionary
for key in table.keys():
value = table[key]
if not index.has_key(value):
index[value] = [] # empty list
index[value].append(key)
return index