in

How to remove objects from array which have swapped keys and values


Is there any way to remove objects from an array which have swapped keys and values?

For example consider this array of objects. In this the name key in first object is equals to the relation key in second object. I want to remove such objects from array in which relation key is equals to name key.

[
  { name: 'Project Manager', relation: 'Engineers' },
  { name: 'Engineers', relation: 'Project Manager' },
  { name: 'Reporting Manager', relation: 'Reportees' },
  { name: 'Reportees', relation: 'Reporting Manager' }
]

Expected output:

[
  { name: 'Project Manager', relation: 'Engineers' },
  { name: 'Reporting Manager', relation: 'Reportees' },
]



Source: https://stackoverflow.com/questions/70634830/how-to-remove-objects-from-array-which-have-swapped-keys-and-values

Medical Pager Chat App powered by GetStream

Simple Game created using Python & PyGame, as my Beginner Python Project