In this python pandas program, we will get elements from the tuple using indexing.
Steps to solve the program
- Create a tuple.
- Get the 2nd element from the front using tuple_name[1].
- Get the 3rd element from the last using tuple_name[-3].
- 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
1 thought on “Python tuple program to get elements from the tuple using indexing”