How to Check if a Tuple Exists in a List in Python
Suppose we have a list of tuples in Python.
lst = [
(1, 2),
(4, 5),
(6, 4)
]
We want to check if a tuple (4, 5)
exists in our list lst
.
if (4, 5) in lst:
print('In the list')
else:
print('Not in the list')