title: TypeError: '_io.TextIOWrapper' object is not subscriptable
body: <p>The main function that the code should do is to open a file and get the median. This is my code:</p>
  <pre><code>def medianStrat(lst):
      count = 0
      test = []
      for line in lst:
          test += line.split()
          for i in lst:
              count = count +1
              if count % 2 == 0:
                  x = count//2
                  y = lst[x]
                  z = lst[x-1]
                  median = (y + z)/2
                  return median
              if count %2 == 1:
                  x = (count-1)//2
                  return lst[x]     # Where the problem persists
  
  def main():
      lst = open(input(&quot;Input file name: &quot;), &quot;r&quot;)
      print(medianStrat(lst))
  </code></pre>
  <p>Here is the error I get:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:/Users/honte_000/PycharmProjects/Comp Sci/2015/2015/storelocation.py&quot;, line 30, in &lt;module&gt;
      main()
    File &quot;C:/Users/honte_000/PycharmProjects/Comp Sci/2015/2015/storelocation.py&quot;, line 28, in main
      print(medianStrat(lst))
    File &quot;C:/Users/honte_000/PycharmProjects/Comp Sci/2015/2015/storelocation.py&quot;, line 24, in medianStrat
      return lst[x]
  TypeError: '_io.TextIOWrapper' object is not subscriptable
  </code></pre>
  <p>I know <code>lst[x]</code> is causing this problem but not too sure how to solve this one.
  So what could be the solution to this problem or what could be done instead to make the code work?</p>