title: Getting median of an unsorted list with selection algorithm
body: <p>I have a list of integers, and I want to use selection to find the median of this unsorted list. This is what I have so far, but I am not getting any output for my test list <code>[140, 240, 180, 400, 340]</code>. Can someone explain what needs to be done to get the median? </p>
  
  <p>My code </p>
  
  <pre><code>def fastSelect(aList, k):
  
      count = 0
      pivot = 0
      smallerList = []
      largeList = []
      while aList != []:
          pivot == len(aList)//2
          for i in range(0,pivot):
              smallerList.append(aList[i])
          for j in range(pivot + 1,len(aList)):
              largeList.append(aList[j])
          for g in range(0,len(aList)):
              if aList[g] == pivot:
                  count += 1
          m = len(smallerList)
          if k &gt;= m and k &lt; m + count:
              return pivot
          if m &gt; k:
              aList = smallerList
          else:
              k = k - m - count
              aList = largeList
  </code></pre>