Guest User

Untitled

a guest
Aug 10th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. attribute_list = [
  2. 'Finish': 'Chrome',
  3. 'Size': 'Large',
  4. 'Weight': '1.6kg',
  5. 'Finish': 'Chrome',
  6. 'Weight': '1.9kg'
  7. ]
  8.  
  9. compiled_list = [
  10. 'Finish': 'Chrome',
  11. 'Size': 'Large'
  12. ]
  13.  
  14. duplicates_list = [
  15. 'Weight': '1.6kg',
  16. 'Weight': '1.9kg'
  17. ]
  18.  
  19. compiled_list = list()
  20. compiled_list_keys = list()
  21. duplicates_list = list()
  22. for attribute in attribute_list:
  23. for k, v in attribute.items():
  24. if k not in compiled_list_keys:
  25. compiled_list_keys.append(k)
  26. compiled_list.append(attribute)
  27. else:
  28. if attribute not in compiled_list:
  29. duplicates_list.append(attribute)
  30. compiled_list_keys.remove(k)
Add Comment
Please, Sign In to add comment