12 versions of the same algorithm in JavaScript, Python, and Go
kentquirk
5011
In python, you can keep a regular dict and use dict.setdefault() instead of dict.get() to reduce the number of line in the loop:
output = dict()
for elem in input: output.setdefault(elem[‘owner’], []).append(elem[‘pet’])