⊗pyPmStPER 114 of 208 menu

Removing an Element from a Set in Python

The discard method can also be used to remove an element from a set. The only difference from the remove method is that it returns the original set rather than an error when the element to be removed is missing.

Let us have a set:

st = {'a', 'b', 'c'}

Let's remove the element 'b' from it:

st.discard('b') print(st) # {'a', 'c'}

Now let's remove the element 'd':

st.discard('d') print(st) # {'a', 'b', 'c'}

Given a set:

st = {'x', 'y', 'z'}

Remove from it the element with value 'y'.

Given a set:

st = {1, 2, 3, 4, 5}

Write the code to get the following result:

{1, 3, 5}

The following code is given:

st = {'ab', 'cd', 'ef'} st.discard('b') print(st)

Tell me what will be output to the console.

dekaenbnhu