Python tuple program to get elements from the tuple using indexing

In this python pandas program, we will get elements from the tuple using indexing.

Steps to solve the program
  1. Create a tuple.
  2. Get the 2nd element from the front using tuple_name[1].
  3. Get the 3rd element from the last using tuple_name[-3].
  4. Print the output.
				
					tup = ('s','q','a','t','o','o','l','s')
print("2nd element from the front in the String: ",tup[1])
print("3rd element from the last in the String: ",tup[-3])
				
			

Output :

				
					2nd element from the front in the String:  q
3rd element from the last in the String:  o
				
			

convert a tuple into a string.

check whether an element exists in a tuple or not.

1 thought on “Python tuple program to get elements from the tuple using indexing”

Leave a Comment