You can’t index (__getitem__
) a _io.TextIOWrapper
object. What you can do is work with a list
of lines. Try this in your code:
lst = open(input("Input file name: "), "r").readlines()
Also, you aren’t closing the file
object, this would be better:
with open(input("Input file name: ", "r") as lst:
print(medianStrat(lst.readlines()))
with
ensures that file get closed, see docs