0
Min/Max list removal help
data = [7, 5, 6.9, 1, 8, 42, 33, 128, 1024, 2, 8, 11, 0.4, 1024, 66, 809, 11, 8.9, 1.1, 3.42, 9, 100, 444, 78] list.remove(min()) list.remove(max()) print(data) #Trying to remove the smallest and largest number from this list. First time learning these functions. What have I done wrong ? Only one test case and I failed it
3 Answers
+ 6
Use 'data' variable instead of 'list'.
min and max function should have at least one parameter:
---> max(iterable)
---> min(iterable)
________________________
data = [7, 5, 6.9, 1, 8, 42, 33, 128, 1024, 2, 8, 11, 0.4, 1024, 66, 809, 11, 8.9, 1.1, 3.42, 9, 100, 444, 78]
data.remove(min(data))
data.remove(max(data))
print(data)
________________________
0
list=[1,4,5,6,]
print('my list: ',list)
print('minimum of list: ',min(list))
print('maximum of list: ',max(list))
list.remove(min(list))
print('after removal of minimum from list: ',list)
list.remove(max(list))
print('after removal of maximum from list: ',list)