title: How can I find the index of the maximum element with recursive functions?
body: <p>For an assignment, I have to find the maximum element's index recursively. How can I do that?</p>
  
  <p>I've tried the following function, but I keep getting wrong results:</p>
  
  <pre><code>def maxElement(A):
      if len(A)==1:
          return A[0]
      else:
          max=maxElement(A[1:])
          if A[0]&gt;max:
              return A[0]
          else:          
              return max
  
  
  A=[9, 16, 100, 36, 4, 25, 1, 81, 49, 9, 64]
  print(maxElement(A))
  </code></pre>
  
  <p>I should get <code>2</code>, since it's the third element, but I keep getting <code>100</code>.</p>