of our file averaging problem slightly this timeinstead of typing the numbers into the file oneper-linewe'll allow any number of values on line when multiple values appear on linethey will be separated by commas at the top levelthe basic algorithm will be some sort of file-processing loop that computes running sum and count for practicelet' use an end-of-file loop here is the code comprising the top-level loopsum count line infile readline(while line !""update sum and count for values in line line infile readline(print("\nthe average of the numbers is"sum countnow we need to figure out how to update the sum and count in the body of the loop since each individual line of the file contains one or more numbers separated by commaswe can split the line into substringseach of which represents number then we need to loop through these substringsconvert each to numberand add it to sum we also need to add to count for each number here is code fragment that processes linefor xstr in line split(",")sum sum eval(xstrcount count + notice that the iteration of the for loop in this fragment is controlled by the value of linewhich just happens to be the loop-control variable for the file-processing loop we outlined above knitting these two loops togetherhere is our programaverage py def main()filename input("what file are the numbers in"infile open(filename,' 'sum count line infile readline(while line !""update sum and count for values in line for xstr in line split(",")sum sum eval(xstrcount count line infile readline(print("\nthe average of the numbers is"sum count