13.4 Loop Sets

By | October 2, 2021

Loop Items

You can loop through the set items by using a for loop:

Example

Loop through the set, and print the values:
thisset = {“apple”, “banana”, “cherry”}
for x in thisset:
 print(x)

Output:
banana
cherry
apple

Leave a Reply

Your email address will not be published. Required fields are marked *