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)

Output :

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

Python Code Editor:

setp = set(["Red", "Green"])
#Clear AKA empty AKA erase
setq = setp.copy()
print(setq)
setq.clear()
print(setq)

Improve this sample solution and post your code through Disqus.



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

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program