Search code examples
pythoncollectionstuples

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

  • You use in.

    if element in thetuple:
        #whatever you want to do.