set.clear() in python



"clear()" function is used to empty the set.




Syntax:




set.clear()







Example-1
n = {10, 20, 30, 10}

n.clear()

print(n)


Output



set()







Example-2
n = {10, 10}

n.clear()

print(n)


Output



set()







Example-3
n = {"A", "B", "AB", "A"}

n.clear()

print(n)


Output



set()