2/9 Exam Statistics


#1

I don't know what I did wrong. Can anyone help? Code is below.

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def print_grades(grades):
total=0
for grade in grades:

    print print_grades(grades)

#2

Almost!
Try this:

def print_grades(grades):
total=0
for grade in grades:
print grade


#3

in addition to whats already said by @designcoder77130
you reduce the function to

def print_grades(grades):
    for grade in grades:
        print grade

when you call it you can just call it like this

 print_grades(grades)

#4

9 posts were split to a new topic: Oops try again! Looks like your code didn't print the grade 100


#13

what's the function of
total = 0


#16

I thought that what they asked us for was:

def print_grades(grades):
    for grade in grades:
        print grade

But the only thing that I could find that was accepted to move on was:

for grade in grades:
    print grade

I then re-read the question: They very clearly asked us to define a function called print_grades which takes one argument (grades). Your error is that you never called the function on your list of grades. There is no need for a total at this point because you're not adding anything to it.

This is the correct code:

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def print_grades(grades):
    for grade in grades:
        print grade
        
print_grades(grades)