I have a data structure that looks like this:
a = {
'red': ['yellow', 'green', 'purple'],
'orange': ['fuschia']
}
This is the code I write to add new elements:
if a.has_key(color):
a[color].append(path)
else:
a[color] = [path]
Is there a shorter way to write this?