How to Loop Through Set to Access Its Items in Python


In this example, we will learn how to loop through the set to access its items in Python.

Source Code

my_set = {'a', 'b', 1, 2, 'c'}

for item in my_set:
    print(item)

Output:

1
2
a
c
b
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments