Check whether an element exists in a tuple or not

In this python tuple program, we will check whether an element exists in a tuple or not.

Steps to solve the program
  1. Create a tuple.
  2. Use an if-else statement to check whether an element exists in the tuple.
  3. 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
				
			

get the 2nd element from the front and the 3rd element from the back of the tuple.

add a list in the tuple.

1 thought on “Check whether an element exists in a tuple or not”

Leave a Comment