Assuming I have a list of tuples like the following:a = [('a','b'), ('c','d'), ('e','f')]
If I were to execute this line 'a' in a I would get False.
Is there a way to tell python "search the just for the first argument and accept whatever in the second"?
So that I could search something like ('a', *) in a and get True?
Try using any (will return True if any of the elements is logically True) with map (to compare each first element in your tuples):
any(map(lambda x: x[0] == "a", a)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With