Gistlib Logo

gistlib

print the value and the index of the largest probability in python

main.py
probabilities = [0.1, 0.3, 0.7, 0.4, 0.9]
max_prob = max(probabilities)
max_index = probabilities.index(max_prob)

print("Largest probability value:", max_prob)
print("Index of the largest probability:", max_index)
215 chars
7 lines

similar python code snippets

get list elements using a list of indices in python
get many elements from a list by index in python
alst = [1, 2, 3, 4, 5, 6] val = alst[len[alst]] in python
output the attribute of a list in python
remove an element from the beginning of an array in python
find the sum of a 5 number list in python
user input that references to values of a list in python
get multiple elements from a list by index in python
remove an element from the end of an array in python
build a list of the numbers from 1 to 100 in python

related categories

python
list
indexing

gistlibby LogSnag