i want to delete Tuples out of a list if they have the same number…
JavaScript
x
2
1
list1 = [(0, 2), (0, 3), (25, 25), (0, 9), (26, 26), (27, 27)]
2
and I need
JavaScript
1
2
1
list2 = [(0, 2), (0, 3), (0, 9)]
2
Thanks a lot!
Advertisement
Answer
Try this:
JavaScript
1
2
1
list2 = [item for item in list1 if item[0] != item[1]]
2