thistuple = ("apple", "banana", "cherry")
for x in thistuple:
print(x)
t=(1,2,3)
for i in t:
print i
myTuple = (1, 2, 3)
for x in myTuple:
print(x)
"""
Output:
1
2
3
"""
myTuple = (1, 2, 3)
i = 0
while i < len(myTuple):
print(myTuple[i])
i = i + 1
"""
Output:
1
2
3
"""
#Loop Through the Index Numbers
#You can also loop through the tuple items by referring to their index number.
#Use the range() and len() functions to create a suitable iterable.
#Print all items by referring to their index number:
thistuple = ("apple", "banana", "cherry")
for i in range(len(thistuple)):
print(thistuple[i])