grahamboree, Super "fun" #Python bug: groupby in itertools ostensibly groups items by the result of a key function, however it just groups similar sequential items in the input list. You can't safely use it directly to build a dictionary. It will silently drop some of your items.
>>> data = ['aa', 'bbb', 'cc']
>>> grouped = {k: list(v) for k, v in groupby(data, key=len)}
>>> print(grouped)
{2: ['cc'], 3: ['bbb']}