Recently, in a paid webinar, someone asked about how to loop through a tuple in Python. So, I decided to write a complete tutorial on various methods to iterate over tuples, including using for loops, while loops, and built-in functions. In this tutorial, I will explain how to iterate through tuples in Python with various examples.
What Are Tuples in Python?
In Python, a tuple is an ordered, immutable collection of elements. Tuples are defined using parentheses () and can contain elements of different data types. For example:
employee = ("John", "Doe", 35, "New York")In this example, we have a tuple called employee that contains a first name, last name, age, and city.
Check out Create a Python Tuple with One Element
Iterate Through Tuples in Python Using a for Loop
The most common way to iterate through a tuple in Python is by using a for loop. The for loop allows you to access each element of the tuple one by one. Here’s an example:
states = ("California", "Texas", "Florida", "New York")
for state in states:
print(state)Output:
California
Texas
Florida
New YorkIn this example, we have a tuple called states that contains the names of some US states. We use a for loop to iterate over each element of the tuple. The loop variable state takes on the value of each element in the tuple, and we print it in each iteration.
You can see the exact output in the screenshot below:

You can also use tuple unpacking to assign multiple variables in each iteration of the for loop, as shown in this example:
employees = [("John", "Doe", 35), ("Jane", "Smith", 28), ("Michael", "Johnson", 42)]
for first_name, last_name, age in employees:
print(f"{first_name} {last_name} is {age} years old.")Output:
John Doe is 35 years old.
Jane Smith is 28 years old.
Michael Johnson is 42 years old.Here, we have a list of tuples called employees, where each tuple represents an employee with their first name, last name, and age. By using tuple unpacking in the for loop, we can assign each element of the tuple to separate variables (first_name, last_name, and age) and use them within the loop.
Check out Get the First Element of a Tuple in Python
Iterate Through Tuples Using a while Loop
Another way to iterate through a tuple is by using a while loop in Python along with the len() function and an index variable. Here’s an example:
cities = ("New York", "Los Angeles", "Chicago", "Houston")
index = 0
while index < len(cities):
print(cities[index])
index += 1Output:
New York
Los Angeles
Chicago
HoustonIn this example, we initialize an index variable to 0. We then use a while loop to iterate over the cities tuple. The loop continues as long as index is less than the length of the tuple, which is obtained using the len() function. Inside the loop, we access each element of the tuple using the index notation cities[index] and print it. Finally, we increment the index variable to move to the next element.
I executed the above Python code using VS code, and you can see the exact output in the screenshot below:

Read How to Access Tuple Elements in Python?
Using the enumerate() Function
Python provides a built-in enumerate() function that allows you to iterate through a tuple while also keeping track of the index. It returns an iterator of tuples, where each tuple contains the index and the corresponding element. Here’s an example:
presidents = ("George Washington", "John Adams", "Thomas Jefferson", "James Madison")
for index, president in enumerate(presidents):
print(f"{index + 1}. {president}")Output:
1. George Washington
2. John Adams
3. Thomas Jefferson
4. James MadisonIn this example, we use the enumerate() function to iterate over the presidents tuple. The enumerate() function returns tuples containing the index and the element. We unpack these tuples into the variables index and president using tuple unpacking in the for loop. We then print the index (incremented by 1 to start from 1 instead of 0) and the corresponding president’s name.
Read How to Print a Tuple in Python?
Iterate Over a List of Python Tuples
Sometimes, you may encounter a list of tuples and need to iterate through each tuple in the list. You can achieve this by using nested loops. Here’s an example:
students = [("Alice", "Smith", 3.8), ("Bob", "Johnson", 3.5), ("Charlie", "Brown", 4.0)]
for student in students:
print(f"Name: {student[0]} {student[1]}")
print(f"GPA: {student[2]}")
print("---")Output:
Name: Alice Smith
GPA: 3.8
---
Name: Bob Johnson
GPA: 3.5
---
Name: Charlie Brown
GPA: 4.0
---In this example, we have a list called students, where each element is a tuple representing a student’s first name, last name, and GPA. We use a for loop to iterate over each tuple in the list. Inside the loop, we access the individual elements of each tuple using index notation (student[0], student[1], student[2]) and print the relevant information.
Read How to Check if a Tuple is Empty in Python?
Using the tuple() Constructor
In some cases, you may have an iterator or a sequence that you want to convert into a tuple before iterating over it. You can use the tuple() constructor to achieve this. Here’s an example:
numbers = [1, 2, 3, 4, 5]
numbers_tuple = tuple(numbers)
for num in numbers_tuple:
print(num)Output:
1
2
3
4
5In this example, we have a list of numbers called numbers. We use the tuple() constructor to convert the list into a tuple called numbers_tuple. We then iterate over the numbers_tuple using a for loop and print each number.
Here is the exact output in the screenshot below:

Conclusion
In this tutorial, I have explained various ways to iterate through tuples in Python. We covered using for loops, while loops, the enumerate() function, iterating over a list of tuples, and using the tuple() constructor. I recommend using the for loops or while loops to iterate through tuples in Python.
You may also like:
- How to Pass a Tuple as an Argument to a Function in Python?
- How to Reverse a Tuple in Python?
- How to Split a Tuple in Python?
- Convert an Array to a Tuple in Python

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.