How to Loop Through Sets in Python
Learn how to iterate over set items in Python using a for loop. See how you can print each item in a set with a simple example demonstrating the loop mechanism.
Loop Sets
Loop Items
You can loop through the set items by using a for loop:
Example
thisset = {"orange", "grape", "mango"}
for x in thisset:
print(x)
Output
orange
grape
mango