'How to check if a tuple contains an element in Python?

I tried to find the available methods but couldn't find it. There is no contains. Should I use index? I just want to know if the item exists, don't need the index of it.



Solution 1:[1]

if "word" in str(tuple):
# You can convert the tuple to str too

i has the same problem and only worked to me after the convert str()

Solution 2:[2]

Be careful with that: return Oops. use Set: d= {...}

def simha():
    d = ('this_is_valid')
    b = 'valid'
    if b in d:
        print("Oops!!!!!")


simha()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 magusvox
Solution 2