Add Items from List Using update() :
thisset = {"apple", "banana", "cherry"}
mylist = ["kiwi", "orange"]
thisset.update(mylist)
print(thisset)
Output :
{'apple', 'banana', 'cherry', 'kiwi', 'orange'}
Remove Item Using remove() :
thisset = {"apple", "banana", "cherry"}
thisset.remove("banana")
print(thisset)
Output :
{'apple', 'cherry'}
Remove Item Using discard() :
thisset = {"apple", "banana", "cherry"}
thisset.discard("banana")
print(thisset)
Output :
{'apple', 'cherry'}
Remove Last Item Using pop() :
thisset = {"apple", "banana", "cherry"}
x = thisset.pop()
print(x)
print(thisset)
Output :
banana
{'apple', 'cherry'}
Clear Entire Set :
thisset = {"apple", "banana", "cherry"}
thisset.clear()
print(thisset)
Output :
set()
Delete Set Completely :
thisset = {"apple", "banana", "cherry"}
del thisset
Output :
NameError: name 'thisset' is not defined