Python deletes the minimum value in the list list and only deletes one

#!/usr/bin/python

my_list = [1, 1, 2, 3, 4, 5, 5]

# Find the minimum and maximum values
min_value = min(my_list)
max_value = max(my_list)

# Remove the minimum and maximum values
my_list.remove(min_value)
print(my_list)  # Output: [1, 2, 3, 4, 5, 5]

my_list.remove(max_value)
print(my_list)  # Output: [1, 2, 3, 4, 5]

remove can only remove one value

 

Guess you like

Origin blog.csdn.net/u013288190/article/details/132011501