- #1
mr.me
- 49
- 0
I was trying to write code that would read integers stored in a file, line by line and then save them to a list and average that list and display it, it didn't work. What can I do to correct this code, I believe that the error is in how I am treating the list but I am confused at why the interpreter can't understand it.
I'm still to this and appreciate the help
-- The attempt at a solution
I'm still to this and appreciate the help
-- The attempt at a solution
Code:
if (os.path.isfile("Testing_1.txt")):
inFile = open("Testing_1.txt", "r")
list_to_av=[ ]
inLine = inFile.readline()
while len(inLine) > 0:
inLine = inFile.readline()
list_to_av.append((inLine))
print int(str(list_to_av))/ len(list_to_av)
inFile.close()
else:
print "Testing_1.txt cannot be found."
Last edited: