I have a main List to store different lists that could be added at any time to main List. The problem I have is to delete the same values from the lists in the main list. So for example:
Initial List of lists:
[[('not', ('box', 'p')), ('diamond', 'p'), ('box', 'q'), ('diamond', 'q'),
('diamond', 'r')], [('not', 'p'), 'q'], ['p', 'q'], ['q', 'q'],
['r', 'q']]
Desired return:
[[('not', ('box', 'p')), ('diamond', 'p'), ('box', 'q'), ('diamond', 'q'),
('diamond', 'r')], [('not', 'p'), 'q'], ['p', 'q'], ['q'], ['r', 'q']]
Second example
Initial:
[[('not', ('box', 'p')), ('diamond', 'p'), ('box', 'q'), ('diamond', 'q'),
('diamond', 'q')], [('not', 'p'), 'q'], ['p', 'q'], ['q', 'q'],
[('not', r'), 'q']]
return
[[('not', ('box', 'p')), ('diamond', 'p'), ('box', 'q'), ('diamond', 'q')],
[('not', 'p'), 'q'], ['p', 'q'], ['q'], [('not', r'), 'q']]
Importantly, order must be the same and only the list inside the main list need not to have duplicates. I have seen many suggestions on stack overflow but none of them work because checking element by element would just leave me with 'diamond' or 'box' values on its own. Where in fact I need ('diamond','q')
tuple to be added in full. This question is different to similar questions because I want to sort a single list inside the main list.