I'm having a bit of trouble. So, for my assignment, my teacher wants us to read in data and output the data into another file. Now, the data we are reading in are Students name(Line one), and their grades(Line 2). Now, he wants us to read them in, then write them into another file. Write them in two lines. Line one, being the students name, and line two, being their average. Then, write the averages into a list and run the whole list through mean, median, and standard deviation. Here's an example of some data from the file.

```
Aiello,Joseph
88 75 80
Alexander,Charles
90 93 100 98
Cambell,Heather
100 100
Denniston,Nelson
56 70 65

```

So, as you see, it's last name first, separated by a comma, then first. Then, on line two, their grades. He wants us to find the average of them and then write them under the students name. That's the part I'm having trouble on. I know how to find an average. Add the grades up, then divide by the number of grades they got. But how do I put that into python? Can anyone help? Also, I already have a mean, median, standard deviation program. How would I put the averages I get from the first part into a list, then putting the whole list through the mean, median, standard devation program.And back to my original question. Is there anything wrong with what I have so far? Anything I need to add/change? Here's my code.

```
def main():
    input1 = open('StudentGrades.dat', 'r')
    output = open('StudentsAvg', 'w')
    for nextLine in input1:
        output.write(nextLine)
    list1 = nextLine.split()
    count = int(list1[3])
    for p in range(count):
        nextLine = input1.readlin()
        output.write(nextLine)
        list2 = nextLine.split()
        name = int(list2[1])
        grades = list2[2]
        pos = grades.index(grade)
        avg =

```