How to remove multiple elements with remove function?
Remove maxs and mins & print the rest. Is there a way without using a & b and without repeating the same structure twice? data = [1, 5, 7, 0.4, 0.4, 9, 9] a = min(data) while a in data: data.remove(a) b = max(data) while b in data: data.remove(b) print(data) #so... while min(data) in data: data.remove(min(data)) #doesn't work, which I expected while min(data) in data: data.remove(min(data)) break #only removes the first of duplicates a = min(data) while a in data: data.remove(a) #works, but could you do it just with functions? Something like: remove the minimum, also until there is a minimum equal to this minimium, remove it, then stop searching for the new minimum 2nd Q: Can you remove different elements using one remove function (remove.data(1,5) or remove.data[1,5] didn't work, I guess the remove function is not meant for that (I'm not yet familiar with del function). Before moving on through lessons I just want to clear some things up)).