title: CS Circles 13 - Coding Exercise: Monkey In The Middle
body: <p>I am currently working through a website called 'Computer Science Circles' and I have reached to question 13 which is all about lists. </p>
  
  <p>The coding exercise is: </p>
  
  <p>Write a function middle(L) which takes a list L as its argument, and returns the item in the middle position of L. (In order that the middle is well-defined, you should assume that L has odd length.) 
  For example, calling middle([8, 0, 100, 12, 1]) should return 100, since it is positioned exactly in the middle of the list. </p>
  
  <p>So far my code looks like this:</p>
  
  <pre><code>def middle(L):
      L = sorted(L)
      n = len(L)
      m = n - 1
      return (L[n/2] + L[m/2] / 2.0)
  </code></pre>
  
  <p>However, every time I run the code, it gives me a </p>
  
  <pre><code>TypeError: list indices must be integers, not float
  </code></pre>
  
  <p>I am not entirely sure how to change my code so that it can run successfully according to the task. </p>