Task
In a given set of integers, you need to remove minimum and maximum elements.
The second argument tells how many min and max elements should be removed.
def removeminmax(data: set, total:int) -> set:
try:
for i in range(total):
data.remove(max(data))
data.remove(min(data))
return data
except:
data
AssertionError:
assert removeminmax({8, 9, 7}, 2) == set()
What is the problem? I'm returning an empty set!
Created at: Jan. 25, 2022, 8:08 p.m.; Updated at: Jan. 25, 2022, 8:21 p.m.
The question is resolved.