I often want to bucket an unordered collection in python. itertools.groubpy does the right sort of thing but almost always requires massaging to sort the items first and cat
Here is a simple two liner
d = {} for x in "thequickbrownfoxjumpsoverthelazydog": d.setdefault(x in 'aeiou', []).append(x)
Edit:
Just adding your other case for completeness.
d={} for x in xrange(21): d.setdefault(x%10, []).append(x)