+ 2
How can i get the position of the smallest number in the list in python?
for example:[6,8,9,1,4] i want show 3(position of the number 1 in the list)
2 Respuestas
+ 4
## if only one min element
lst1=[6, 8, 9, 1, 4]
minNum=min(lst1)
indexOfMinNum=lst1.index(minNum)
print (indexOfMinNum)
## if multiple min element
lst2=[6,1,8,1,1,9]
minNum=min(lst1)
print([i for i in range (len(lst2)) if lst2[i]==minNum])
+ 1
thanks❤️