anagram finder / dict mapping question
Paul Rubin
http
Thu May 8 20:01:42 EDT 2008
dave <squareswallower at 1ya2hoo3.net> writes:
> if newtlist not in mapdic:
> mapdic[newtlist] = [line]
> if line not in mapdic[newtlist]:
> mapdic[newtlist].append(line)
I'd use the defaultdict module to avoid the above.
> for value in mapdic.values():
> if len(value) <= 1:
> pass
> else:
> print value
I'd write:
for value in mapdic.values():
if len(value) > 1:
print value
I'd actually use itervalues rather than values, but that's a little
bit fancy, you don't have to worry about it til later.
More information about the Python-list
mailing list