In this python tuple program, we will check whether an element exists in a tuple or not.
Steps to solve the program
- Create a tuple.
- Use an if-else statement to check whether an element exists in the tuple.
- Print True if the element exists in the tuple else print False.
tup = ('p','y','t','h','o','n')
if 'p' in tup:
print("True")
else:
print("False")
Output :
True
1 thought on “Check whether an element exists in a tuple or not”