I have a list say a = [5,3,1,4,10]. I need to get indices of the top two values of the list, that is for 5 and 10 I would get [0, 4]. Is there a one-liner that Python offers for such a case?
I have a list say a = [5,3,1,4,10] . I need to get indices
Share
or
or
or (for long lists), consider using
heapq.nlargest