title: (python) SyntaxError: invalid syntax in def function
body: <pre><code>  File &quot;stats0.py&quot;, line 40
      def median(numbers):
        ^
    SyntaxError: invalid syntax
  </code></pre>
  
  <pre><code>def median(numbers):
      numbers.sort()
      size = len(numbers)
      midPos = size/2
      if size%2==0:
          median = (numbers[midPos]+numbers[midPos-1])/2.0
      else:
          median = numbers[midPos]
      return median
  </code></pre>
  <p>I keep getting this error. I have tried commenting it out but each 'def' has an error. I also looked at each previous questions regarding this error. As far as my understanding, indentation is correct. Please help, this is the first time I have received such an error. (was following a book's code)</p>