determine the minimum element, and then check it for other elements in the list.
def locate_min(a):
smallest = min(a)
return smallest, [index for index, element in enumerate(a)
if smallest == element]
which will return the tuple (min_element, [location, location, ...]). If I understand you correctly, this is what I think you want. For instance:
>>> locate_min([1, 2, 1, 1, 4, 5, 6])
(1, [0, 2, 3])
. , for-loop. ( , , )
def locate_min(a):
min_indicies = []
smallest = min(a)
for index, element in enumerate(a):
if smallest == element:
min_indicies.append(index)
return smallest, min_indicies