w3resource logo

:

Python Exercises

Python Exercise: Clear sets

Python sets: Exercise-12 with Solution

Write a Python program to clear a set.

Sample Solution:-

Python Code:

setp = set(["Red", "Green"])
setq = setp.copy()
print(setq)
setq.clear()
print(setq)

Sample Output:

{'Green', 'Red'}                                                                                              
set() 

Python Code Editor:

Improve this sample solution and post your code through Disqus