How to Delete Set Completely in Python


In this example we will show how to delete the set completely using the del keyword in Python.

Source Code

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

del my_set

print(my_set)

Output:

Traceback (most recent call last):
  File "demo.py", line 5, in 
    print(my_set)
NameError: name 'my_set' is not defined
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments