input: [("abc", 1, "def"), ("abc", 1, "ghi"), ("bc", 2, "a"), ("bc", 2, "b"), ("bc", 3, "a")]
expected output: [("abc", 1, "def"), ("bc", 2, "a"), ("bc", 3, "a")]
I was trying something like:-
field_list = [field for i, field in enumerate(field_list) for cmp_field in field_list[i+1:] if]
.....don't know how if
would suit here?
I wanted to achieve this using list comprehension. Logic for getting output -- remove the duplicates(tuple is treated as duplicate if item[0] and item[1] are same).
I could achieve it using traditional for loops but I would like to get this with list comprehension. Any thoughts?
Edit: ("abc", 1, "def") and ("abc", 1, "ghi") are duplicates, so I can pick the first one.