Hello everyone, I am new to python, and started off by doing some excersises. I came with a working code, but after I tried to group it into functions, the code didn't give me the right output anymore. Can someone please show me what went wrong? Thanks in regards.
def averages(line, average_grade): if line == '': return name_grades = line.split('_') student_name = name_grades[0] grades = [float(n) for n in name_grades[-1].split(' ')] average_grades(student_name, grades) print('{} has an average grade of {:.2}'.format(student_name, average_grade))
def average_grades(grades): average_grade = sum(grades) / len(grades) averages(average_grade) return
file = open('geo_grades_1_input.txt').read().split('\n') print("Report for group 2b")
for line in file: averages(line)
print("End of report")