EN
Python - min value in an array
0 points
This article will show you how to find the minimum value in an array in Python.
xxxxxxxxxx
1
array = [3, 2, 7, 5]
2
3
print(min(array)) # 2
xxxxxxxxxx
1
import math
2
3
4
def min_value(array):
5
result = math.inf
6
7
for item in array:
8
if item < result:
9
result = item
10
11
return result
12
13
14
numbers = [2, 3, 8, 1, 5]
15
16
print(min_value(numbers)) # 1