I don't see how your code got that far. Your readData() function is reading into local variables (stats, stats1), which get deleted as soon as the function returns. (Also, were you supposed to read stats1 from infile1? Right now you're reading both from infile.)
The TypeError exceptions seems to be happening because you are trying to use sum() on a list of strings. You don't convert the results of split() into floats anywhere. More about that below.
One way to solve the local variable problem is to use global variables. That's not the best habit to get into, since globals tend to make "brittle" programs that are hard to modify and "refactor" as they grow and as requirement evolve. In each function that uses them (including main), add the statement:
global stats, stats1
...before any use of either of them.
I think it's better for the input function to return those lists to main() and for main to pass them as arguments to other functions. One nice way to do this (if the assignment allows for it) is to pass the file name to the readData() function, with something like:
def readData(fname):
.... infile = open(fname)
.... stats = []
.... for s in infile.read().split():
.... .... stats.append(float(s))
.... return stats
That will read a specified file and convert all string values to floats. The resulting list is returned as a function result. Then, main() can:
.... stats_hwy = readData( "carModelData_hwy" )
.... stats_city = read_data( "carModelData_city" )
and the pass those lists to avgData() with:
.... avgData(stats_city, stats_hwy)
Update the header of avgData() to:
def avgData(stats, stats1):
...using the old names if you like. I'd change stats to stats_city and stats1 to stats_hwy, so that the variable name says what the variable contains. You might prefer statsCity and statsHwy to match the camelCase naming style that you're using for function names. I tend to follow the styles that the Python libraries use.
Notice how the new version of readData() means you only write (or change!) the file input code once, instead of twice to get both files read. The only differences were the file names and the names of the resulting list of values, and that's handled nicely by arguments and return values.