w3resource logo


Python Exercises

Python Exercise: Create a new empty set

Python sets: Exercise-1 with Solution

Write a Python program to create a new empty set.

Sample Solution :-

Python Code :

#Create a new empty set 
x = set()
print(x)
#Create a non empty set
n = set([0, 1, 2, 3, 4])
print(n)

Output :

>>>
set()
{0, 1, 2, 3, 4}
>>>

Python Code Editor:

#Create a new empty set
x = set()
print(x)
#Create a non empty set
n = set([0, 1, 2, 3, 4])
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