I don't mean situation like this:
my_list = [("a", "b"), ("c", "d"), ("d", "f"), ("a", "b"), ("b", "c")]
and eliminating the second tuple ("a", "b")
, but rather something like:
my_list = [("a", "b"), ("c", "c"), ("d", "f"), ("a", "b"), ("b", "b")]
and removing tuples ("c", "c")
and ("b", "b")
.
In the example above, the following one-liner does the job:
my_list_cleared = [n for n in my_list if n[0] != n[1]]
But is there also a one-liner if there are three and more elements in tuples (like: ("a", "a", "b", "c")
)?