I have a list of lists in Python and want to remove duplicates with each element being compared and yes, I care (the most) about the order of the list.
I have already looked at most of the solutions on stack overflow. For e.g. the one here, solution voted doesn't compare the elements of list of lists and would fine for the given use case, provided it's sorted. However, what I'm looking for is:
What's available
s1 = ['Lucifer', 'Ella']
s2 = ['Lucifer', 'Eve']
s3 = ['Chloe', 'Lucifer']
s4 = ['Lucifer', 'Linda']
What's required
As I said, care about the order, remove duplicate from each list (that's why 'Lucifer' is missing from the list) and get only unique ones..
['Ella', 'Eve', 'Chloe', 'Linda']
Caution: It will not always be the first element that would be common across list for e.g. in s4 it can be 'Amenadiel'. For now let's assume that length of lists to be compared is always 2.
What have I tried
list((set(s1) ^ set(s2) ^ set(s3) ^ set(s4)) ^ (set(s1) & set(s2) & set(s3) & set(s4)))
the output from above is ['Chloe', 'Eve', 'Linda', 'Ella', 'Lucifer']
which is not as expected (as mentioned above!).
This was working fine with two or three list, but isn't working with four list.
Please help!
TIA.