w3resource logo


Python Exercises

Python Exercise: Iteration over sets

Python sets: Exercise-2 with Solution

Write a Python program to iteration over sets.

Sample Solution :-

Python Code :

#Create a set 
num_set = set([0, 1, 2, 3, 4, 5])
for n in num_set:
print(n)

Output :

0
1
2
3
4
5

Python Code Editor:

#Create a set
num_set = set([0, 1, 2, 3, 4, 5])
for n in num_set:
	print(n)

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.

Solve these problems:

Python: How to check whether a file exists using Python?

C#: Loops in c#

PHP: For each

SQL: JOIN using more than 5 tables

JavaScript: Blank Slide in Javascript Slideshow