How to find all positions of the minimum value in a list?
thelist = [5, 2, 4, 9, 7, 2, 9] min_value = min(thelist) min_indexes = [i for i, j in enumerate(thelist) if j == min_value] print(min_indexes)
Output
[1, 5]
thelist = [5, 2, 4, 9, 7, 2, 9] min_value = min(thelist) min_indexes = [i for i, j in enumerate(thelist) if j == min_value] print(min_indexes)
[1, 5]