Answer the question
In order to leave comments, you need to log in
Is there a more canonical and beautiful way to get the list?
let
icons = [{event_id:1, x:1},{event_id:2, x:2},{event_id:1, x:3}]
how to get a list of icons with unique event_ids. i.e. [{event_id:1, x:1},{event_id:2, x:2}]
my version:
tmp = set()
unic = set()
for icon in icons:
if not icon['event_id'] in tmp:
unic.add(icon)
tmp.add(icon['event_id'])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question