Shorter Set Error
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: dataAssertionError: assert removeminmax({8, 9, 7}, 2) == set()
What is the problem? I'm returning an empty set!