Oops, try again. Your function caused the following error: maximum recursion depth exceeded


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/3/1?curriculum_id=4f89dab3d788890003000096#


Oops, try again. Your function caused the following error: maximum recursion depth exceeded


can anyone tell me where is my mistake or give me the corrected code ?:grinning:


Replace this line with your code. 

n = [3, 5, 7]

for i in range(0, len(n)):
    print n[i]
def print_list(n):
    return print_list(n)


#2

the for loop should be inside the function and i would place this line:

return print_list(n)

after the function, but then with a print statement rather then return

The problem here is, that you call the function from inside the function, a sort of infinity loop


#3

so what should I do or can u give me the right code to see my mistake?


#4

i can not, the guidelines prevent me. If after you made improvements to your code it is still not working, post an updated version of your code


#5

n = [3, 5, 7]


def print_list(n):
    for i in range(0, len(n)):
        print n[i]
    return print_list(n)

ops, try again. Your function caused the following error: maximum recursion depth exceeded while calling a Python object


#6

your function call:

return print_list(n)

is still inside your function, change the indent so it outside the function


#7

n = [3, 5, 7]


def print_list(x):
    for i in range(0, len(n)):
        print n[i]
return print_list(n)

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

File "python", line 7
SyntaxError: 'return' outside function


#8

return keywords can only occur inside function, remove the return keyword. But i already mentioned this earlier:


#9

n = [3, 5, 7]


def print_list(x):
    for i in range(0, len(n)):
        print n[i]
print print_list(n)

Oops, try again. The body of your function should not contain any references to 'n'


#10

ok , It so kind of you to help me .
I got the mistake thank you a lot.
sorry for asking you many times .:sweat_smile: