Example: It Is Also Possible To Use The Constructor To Make A Set
Example: It Is Also Possible To Use The Constructor To Make A Set
Set is one of 4 built-in data types in Python used to store multiple items in a single
variable.
Example
Create a Set:
<class 'set'>
thisset.add("bachupally")
print(thisset)
thisset.update(myset)
print(thisset)
thisset.remove("grade8")
print(thisset)
thisset.discard("cbse")
print(thisset)
thisset.pop()
print(thisset)
Output: {“cbse”,"grade8"}
4. The clear() method empties the set:
thisset.clear()
print(thisset)
Output: {}
del thisset
print(thisset)