values = [2.991026919242273, 0.4985044865403789, 4.885343968095713, 2.4925224327018944, 0.19940179461615154, 2.193419740777667, 4.586241276171486, 9.970089730807578, 23.230309072781655, 2.8913260219341974, 1.7946161515453638, 4.287138584247258, 17.547357926221338, 0.3988035892323031, 1.3958125623130608, 0.29910269192422734, 6.580259222333001, 5.18444666001994, 1.296111665004985, 3.8883349950149553, 2.7916251246261217, 0.7976071784646062, 7.676969092721834, 1.5952143569292123, 6.181455633100698, 2.293120638085743, 2.691924227318046, 4.087736789631107, 0.0, 0.09970089730807577, 2.293120638085743, 1.9940179461615155, 11.266201395812562]
my_probability = 5.0
result = min(values, key=lambda x:abs(x-my_probability))
Python3