Code :
s = set([1, 0, 2, 0, 3])
s.remove(0)
print(s)
Solution and Explanation:
The remove() method in a set in Python removes the specified element. In your code:
s = set([1, 0, 2, 0, 3])
s.remove(0)
print(s)
It removes the element 0 from the set s. The output will be a set without the removed element:
{1, 2, 3}
0 Comments:
Post a Comment