Hi guys, first off just wanted to say that this website has been immensely helpful to me for my programming class. I asked a question to help with a lab a couple of weeks ago and was able to figure out the issue with the forums help, so thank you. As last time, I am not looking for the lab to be done for me, only to be pushed in the right direction.
Lab: Write a Python program which will read integer data from a text file, convert these string values to integers, create a list containing these integers, and then compute and output the average of the values stored in the list.
I am confused on how to convert the list into integers in a list which can than be computed. We have to use a function to compute the average.
So far my code is:
def avgcalc(myList): average = total/numcount return average myFile = open("labIn.txt", "r") for myLine in myFile: print myLine,
Obviously I still have a lot of work to do, right now it simply prints the numbers that are in the .txt file. I just have no idea how to take these numbers from the file and put them in a list. Thanks in advance daniweb!
I wanted to specifiy that the txt file contains this following:
Edited 5 Years Ago by bigredaltoid: Added context