Google News
logo
Python Program to Loop through a Tuple
In the following example of Python program that demonstrates how to loop through a tuple :
Program :
# create a tuple
my_tuple = ('apple', 'banana', 'cherry')

# loop through the tuple
for item in my_tuple:
    print(item)
Output :
apple
banana
cherry
In the above example, we first create a tuple called `my_tuple` that contains three elements. We then use a `for` loop to iterate over the elements of the tuple. For each element, we print it to the console.