Skip to content

Instantly share code, notes, and snippets.

@kentquirk
Created September 10, 2016 17:54
Show Gist options
  • Save kentquirk/331718543bf4802d07882681259e7d8c to your computer and use it in GitHub Desktop.
Save kentquirk/331718543bf4802d07882681259e7d8c to your computer and use it in GitHub Desktop.
No explicit conditional
output = dict()
for element in input:
item = output.get(element["owner"], [])
item.append(element["pet"])
output[element["owner"]] = item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment