Python Check if Tuple Item Exists


Check if Tuple Item Exists

To determine if a specified item is present in a tuple use the in keyword:

Example

Check if "apple" is present in the tuple:

thistuple = ("apple", "banana", "cherry")
if "apple" in thistuple:
  print("Yes, 'apple' is in the fruits tuple")
Try it Yourself »


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.