Python Program to Get Tuple Items

Write a Python program to get or access tuple items with an example. In Python, we can access tuple items using the positive and negative index positions. In this Python example, we get or retrieve, or access the tuple items using both the positive and negative index position.

# Get Tuple Items

intTuple = (10, 20, 30, 40, 50, 60, 70, 80, 90)
print("Tuple Items = ", intTuple)

fourthItem = intTuple[3]
print("Tuple Fourth Item = ", fourthItem)

firstItem = intTuple[0]
print("Tuple First Item = ", firstItem)

fourthItemfromLast = intTuple[-4]
print("Tuple Fourth Item from Last = ", fourthItemfromLast)

sixthItemfromLast = intTuple[-6]
print("Tuple Sixth Item from Last  = ", sixthItemfromLast)
Python Program to Get Tuple Items 1

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.