Get the smallest value from a Python list (array).

Get the smallest value from a Python list (array).

The following Python code will get the smallest value from within a Python List.


matches = []

matches.append(0.12)

matches.append(0.42)

matches.append(0.71)

matches.append(0.94)

matches.append(0.03)

matches.append(0.85)

best_match = min(float(dist) for dist in matches)

print(best_match)

Will print the smallest value to stdout.


0.03

Leave a Reply