how to remove duplicates dict from the list of dictionary based on one of the elements is duplicate in list of dict

Iranna Mathapati iranna.gani28 at gmail.com
Sun Nov 17 01:56:53 EST 2019


Hi,

How to remove duplicates dict from the list of dictionary based on one of
the duplicate elements in the dictionary,

l = [{"component":"software", "version":"1.2" },
     {"component":"hardware", "version":"2.2",},
     {"component":"driver",   "version":"3.2",},
     {"component":"firmware", "version":"4.2",},
     {"component":"software", "version":"1.9",},
     {"component":"hardware", "version":"2.7",}
    ]

need to remove the dict if having same components [in the above example
components "software" and "hardware" is duplicated twice

expected output:

    [{"component":"software", "version":"1.2" },
     {"component":"hardware", "version":"2.2",},
     {"component":"driver",   "version":"3.2",},
     {"component":"firmware", "version":"4.2",}
    ]


More information about the Python-list mailing list