2. print those grades error


#1

"Oops, try again. Your print_grades function threw the following error: maximum recursion depth exceeded while calling a Python object"

Hi here's my code,

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

def print_grades(grades):
for n in grades:
print n
return print_grades(grades)

What am I doing wrong?


#2

The problem is here:

You are calling the function in it's own definition.
I don't think you need to return anything, so just leave out that line.


#3

@captaincajun Your return statement is what is messing the code up. If you remove the return statement, and make your code look like this, then you should be fine. :slight_smile:

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)

Hope that works for you! Let me know if you need more help after that, or need anything else.:grinning:

@chipjumper36731




#4

Hey thanks! You are a life-saver lol


#5

Hey! No problem! Glad to help! :slight_smile:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.