How to use in operator to check if a value is in tuple in Python

Membership and in operator

We can use in operator to check if a value is in a tuple. The in operator returns true if the value is found and returns false if not found.


t = (['xyz', 123], 23, -103.4)
print 23 in t
print 123 in t

The code above generates the following result.





















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary