Python Program to Print Tuple Items

Write a Python Program to print the list of total items in a tuple. We can use the print function to print the whole tuple. In this example, we declared string and int tuples and prints them.

numTuple = (10, 20, 30, 40, 50)

print("The Tuple Items are ")
print(numTuple )

strTuple = ('C#', 'Java', 'Python', 'C')

print("\nThe String Tuple Items are ")
print(strTuple ) 
Python Program to Print Tuple Items 1

In this Python Program, we use for loop range to access each tuple item. The first for loop iterate from the first tuple item to the last and print each element. And the second loop prints all the fruits in the string tuple.

# Python Program to Print Tuple Items

numTuple = (10, 20, 30, 40, 50)

print("The Tuple Items are ")
for i in range(len(numTuple)):
    print("Tuple Item at %d Position = %d" %(i, numTuple[i]))           

print("=========")
fruitsTuple = ('apple', 'orange', 'kiwi', 'grape')
for fruit in fruitsTuple:
    print(fruit)
The Tuple Items are 
Tuple Item at 0 Position = 10
Tuple Item at 1 Position = 20
Tuple Item at 2 Position = 30
Tuple Item at 3 Position = 40
Tuple Item at 4 Position = 50
=========
apple
orange
kiwi
grape

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.