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.

# Print Tuple Items

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.

# 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