"W. eWatson" <wolftra...@invalid.com> writes: > See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.
Here are a few ways. >>> a = [1,4,9,3] >>> max_index = max(xrange(len(a)), key=a.__getitem__) >>> max_index 2 >>> # Or: ... max_index = max((n, i) for i, n in enumerate(a))[1] >>> max_index 2 >>> # Or: ... from itertools import * >>> max_index = max(izip(a, count()))[1] >>> max_index 2 -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list