Get The Most Affordable Hosting in the World!
Starting at just $1.87/month, Vercaa offers unbeatable pricing for world-class web hosting services.
Fast, reliable, and secure hosting to power your website without breaking the bank. Plus, enjoy a free CDN for faster loading times worldwide!
Get Started Now!You can traverse the items in a tuple with Python's for loop construct. The traversal can be done, using tuple as an iterator or with the help of index.
Syntax
Python tuple gives an iterator object. To iterate a tuple, use the for statement as follows −
Example 1
The following example shows a simple Python for loop construct −
It will produce the following output −
25 12 10 -21 10 100
Example 2
To iterate through the items in a tuple, obtain the range object of integers "0" to "len-1".
It will produce the following output −
tup1[0]: 25 tup1 [1]: 12 tup1 [2]: 10 tup1 [3]: -21 tup1 [4]: 10 tup1 [5]: 100
The End! should you have any inquiries, we encourage you to reach out to the Vercaa Support Center without hesitation.