With Python's built-in library, it's pretty easy:
a = [2, 9, -10, 5, 18, 9]
max(xrange(len(a)), key = lambda x: a[x])
This tells max
to find the largest number in the list [0, 1, 2, ..., len(a)]
, using the custom function lambda x: a[x]
, which says that 0
is actually 2
, 1
is actually 9
, etc.