title: Finding index of maximum element from list
body: <p>Let v be a list of numbers</p>
  
  <pre><code>v = [3,5,2,4,8,6,1]
  </code></pre>
  
  <p>Why the following code to find the max element and its index gives an error ? ('int' object is not subscriptable)</p>
  
  <pre><code>reduce(lambda x,y: max(x[1],y[1]), enumerate(v))
  </code></pre>
  
  <p>P.S. I know there are other ways to do it, like the one below but I want to understand why the previous one does not work.</p>
  
  <pre><code>max(enumerate(v), key= lambda x: x[1])
  </code></pre>
  
  <p><strong>Epilogue</strong></p>
  
  <p>Simeon pointed out that my code was really wrong cause lambda should have returned a tuple, not a number. Understanding this, my code could be easily fixed in the following way:</p>
  
  <pre><code>reduce(lambda x,y: x[1]&lt;y[1] and y or x, enumerate(v))
  </code></pre>
  
  <p>which is, by the way, about 30% slower than</p>
  
  <pre><code>max(enumerate(v), key= lambda x: x[1])
  </code></pre>