[Solved] How to not hardcode function in this example


As both sets of your data start the same place the following works
for idx,i in enumerate(range(4,len(grades_list))):

This should fulfill all requirements that Im aware of up to this point

def class_avg(open_file):
    '''(file) -> list of float
    Return a list of assignment averages for the entire class given the open
    class file. The returned list should contain assignment averages in the
    order listed in the given file.  For example, if there are 3 assignments
    per student, the returned list should 3 floats representing the 3 averages.
    '''
    marks = None
    avgs = []
    for line in open_file:
        grades_list = line.strip().split(',')
        if marks is None:
            marks = []
            for i in range(len(grades_list) -4):
                marks.append([])
        for idx,i in enumerate(range(4,len(grades_list))):
            marks[idx].append(int(grades_list[i]))
    for mark in marks:
        avgs.append(float(sum(mark)/(len(mark))))
    return avgs

solved How to not hardcode function in this example