S
S
s4q2020-06-20 02:01:29
Python
s4q, 2020-06-20 02:01:29

How to remove duplicates in the list of dictionaries?

Let's say we have a list of dictionaries like this:

els = [{'check': 22}, {'check': 22}, {'check2': 33}]

How to remove extra dictionaries so that only check and check2 remain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aRegius, 2020-06-20
@s4q

unique_els = []

for dict_item in els:
    if dict_item not in unique_els:
        unique_els.append(dict_item)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question