title: Finding the middle object of a list
body: <p>I need help with this python 3 exercise, to find the median of a list. you're supposed to define and make your own function, and that's what i did.</p>
  
  <p>EXERCISE:</p>
  
  <blockquote>
    <p>Write a function <code>middle(L)</code> which takes a list <code>L</code> as its argument, and returns the item in the middle position of <code>L</code>. (In order that the middle is well-defined, you should assume that <code>L</code> has odd length.) For example, calling <code>middle([8, 0, 100, 12, 1])</code> should return <code>100</code>, since it is positioned exactly in the middle of the list.</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>def middle(a):
      a = sorted(a)
      l = len(a)
  
      if len(a) % 2 == 0.:
          m = (a[int(l / 2)] + a[int(l / 2) - 1]) / 2.
      else:
          if l &lt; 2:
              m = a[0]
          else:
              m = a[int(l / 2)]
  
      return m
  </code></pre>
  
  <p>when I tried this in another site, it worked. But I get the following error when I put it in this site:</p>
  
  <blockquote>
    <p>Program executed without crashing.
        The grader said:
        Running middle([8, 0, 100, 12, 1]) … Error: middle([8, 0, 100, 12, 1]) has wrong value 8, expected 100</p>
  </blockquote>
  
  <p>The argument name being <code>a</code> instead of <code>L</code> has nothing to do with the wrong answer as I already tried changing it to <code>L</code>.</p>
  
  <p><strong>update</strong></p>
  
  <p>THANK YOU FOR THE HELP. IT WORKED WHEN i REMOVED THE <code>A = SORTED(A)</code> CHUNK.</p>