Check if word is inside of list of tuples

python, python-3.x

Solution

May be use a hash

>>> word in dict(list_of_tuples)

Problem

I'm wondering how I can efficiently check whether a value is inside a given list of tuples. Say I have a list of: ``` ("the", 1) ("check", 1) ("brown, 2) ("gary", 5) ``` how can I check whether a given word is inside the list, ignoring the second value of the tuples? If it was just a word I could use ``` if "the" in wordlist: #... ``` but this will not work, is there something along the line this i can do? ``` if ("the", _) in wordlist: #... ```

Original source