I have a list of dictionaries and I would like to remove all dicts that are duplicates in number
. Keep only the last!
Example:
List of dicts:
student_data = [{'number':'1234', 'url':'www.abc.com'}, {'number':'9999', 'url':'www.abc.com'}, {'number':'1234', 'url':'www.xyz.com'}]
As you can see in we have 2 dicts where number
is 1234. Therefore I remove the first dict and keep the last:
List of dicts:
student_data = [{'number':'9999', 'url':'www.abc.com'}, {'number':'1234', 'url':'www.xyz.com'}]
Any idea how to do this?