Python – Loop Tuples

1. What Does “Loop Tuples” Mean?

Looping a tuple means going through each item one by one.

In simple words:
👉 Python reads every value inside the tuple.

2. Loop Through Tuple Using for

The easiest and most common way.

Example

fruits = ("apple", "banana", "orange")

for fruit in fruits:
print(fruit)

Output:

apple
banana
orange

3. Loop Through Tuple Using Index

You can loop using index numbers.

Example

colors = ("red", "blue", "green")

for i in range(len(colors)):
print(colors[i])

4. Loop Through Tuple Using while

Example

numbers = (10, 20, 30)
i = 0

while i < len(numbers):
print(numbers[i])
i += 1

5. Loop with Tuple Unpacking

Example

students = (("Amit", 20), ("Ravi", 22))

for name, age in students:
print(name, age)

6. Loop and Use Condition

Example

nums = (5, 10, 15, 20)

for n in nums:
if n > 10:
print(n)

7. Loop Through Tuple with enumerate()

Example

fruits = ("apple", "banana", "orange")

for index, value in enumerate(fruits):
print(index, value)

8. Common Beginner Mistakes

❌ Trying to Change Tuple in Loop

for i in range(len(fruits)):
fruits[i] = "mango"

❌ Error: tuple cannot be changed.

❌ Forgetting Index Start at 0

print(fruits[1]) # second item, not first

9. Simple Practice Examples

Example 1: Print All Items

items = ("pen", "book", "eraser")

for item in items:
print(item)

Example 2: Print Index and Value

nums = (100, 200, 300)

for i, n in enumerate(nums):
print(i, n)

Example 3: Count Items

count = 0
for _ in nums:
count += 1

print(count)

10. Summary (Loop Tuples)

✔ Tuples can be looped easily
for loop is simplest
✔ Index-based loop works
✔ Tuples are read-only
✔ Useful for fixed data

📘 Perfect for Beginner eBook

This chapter is ideal for:

  • Python beginner books

  • School & college students

  • Self-learners

If you want next, I can write:

  • Join Tuples

  • Tuple Methods

  • Tuple Exercises

  • Sets (easy)

Just tell me 😊

You may also like...