Python - Loop Sets
Loop Items
You can loop through the set items by using a for
loop:
ExampleGet your own Python Server
Loop through the set, and print the values:
thisset = {"apple", "banana", "cherry"}
for x in thisset:
print(x)
Try it Yourself »
Exercise?What is this?
Test your skills by answering a few questions about the topics of this page
What is a correct syntax for looping through the items of a set?