Programming Examples
Write a Python program to check whether an element exist within a tuple.
Write a Python program to check whether an element exist within a tuple.
Solutiont = (10, 20, 30, 40, 50)
element = int(input("Enter an element to search: "))
if element in t:
print("Element exists in the tuple.")
else:
print("Element does not exist in the tuple.")
▶ RUN Output/ Explanation: Uses the in keyword to check membership.
Works for any data type, not just integers.