Wrong output
Hello everyone, I made this code to calculate the average grades for four students in the list called 'studentgrades;. I want the code to calculate the average grade for every student in the list. If i run it, it returns the average of the first two lists. but i want it to output the average for every single list I hope i made it clear, if its not please ask me. studentGrades = [[95, 92, 86],[66, 75, 54],[89, 72, 100],[34, 0, 0]] def average_per_student(studentGrades): res = 0 loopCount = 0 answer = [] for row in studentGrades: for item in row: loopCount = loopCount + 1 res = res + item average = res / loopCount answer.append(average) return answer def average_all_students(studentGrades): som = 0 answer = 0 loopCount = 0 for row in studentGrades: for item in row: som = som + item loopCount = loopCount + 1 total = answer + som #loopCount = loopCount + 1 antw = total / loopCount return antw print(average_per_student(studentGrades)) print(average_all_students(studentGrades))