python <w.g.sned...@gmail.com> writes:

> tag23gr is a list of lists each with two items.
> g23tag is an empty dictionary when I run the for loop below.
> When is is complete each key is a graphic name who's values are a list
> of tags.
>
> for item in tag23gr:
> ...   value, key = tuple(item)
> ...   if(g23tag.get(key)):
> ...           g23tag[key].append(value)
> ...   else:
> ...           g23tag[key] = [value]

for item in tag23gr:
    g23tag.setdefault(item[0],[]).append(item[1])

-- Alain.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to