I have a list a, then I use max(a) to get the max values. Next step I am trying to use enumerate() to get the first position of max values. But it notices that I could only use enumerate() for int lists? How about float lists? Is there any way to get the 1st position of max values in a float(also with int) list? Thanks a lot
a = [1.5, 1.8, 3.1, 4.2, 5.5, 3.2, 4, 2, 1, 5.5, 3, 2.7]
b = max(a)
maxIndex = [i for i, j in enumerate(b) if j == b][0]
Traceback (most recent call last): File "", line 1, in TypeError: 'float' object is not iterable
enumerate(b)?bis a float, not a list. Did you meanenumerate(a)? - BrenBarn