Tuesday, March 27, 2018

Removing Item from a Set


Removing Item from a Set

We can remove elements from a set by using discard method. Again as discussed there is no specific index attached to the newly added element.

Days=set(["Mon","Tue","Wed","Thu","Fri","Sat"])

Days.discard(“Sun”)
Print (Days)

When the above code is executed, it produces the following result.

set(['Wed', 'Fri', 'Tue', 'Mon', 'Thu', 'Sat'])





<<< Adding Items                        Go to Index                   Union of Sets >>>