Skip to content Skip to sidebar Skip to footer

Internal Min Function Of Python

I need to know how the min function of python works if there are more than one item in a list which are minimum. Which one takes min? Say A = [5, 3, 1, 4, 1]. Now if I say A.remove

Solution 1:

In this case it will remove the first one. It's more about the behavior of the list.remove function rather than the min function in this case. min just returns the lowest value in the list so it returns the integer 1. list.remove removes the leftmost instance of the parameter passed to it.

Also, as answered in this answer to the question that mgilson linked above, if you are dealing with objects rather than values (i.e. lists rather than integers), the first one matching the minimum value will be selected.


Post a Comment for "Internal Min Function Of Python"