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

I am confused

Here is the code:

```
n = [3, 5, 7]
for i in range(0, len(n)):
def print_list(x):
return print_list(x)
print n[i]
```

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

I am confused

Here is the code:

```
n = [3, 5, 7]
for i in range(0, len(n)):
def print_list(x):
return print_list(x)
print n[i]
```

you are calling a function within a function(recursion) but there is no base or termination case so there is infinite computation till the system runs out of resources. That's what the error is telling you

I changed the code by removing the function in the function. I set the function to return x' instead. And I am getting this error:

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

Where am I getting it wrong and how do I resolve it?

Code:

n = [3, 5, 7]

for i in range(0, len(n)):

def print_list(x):

return x

print n[i]

define a function before for i in range so that the following

def print_list(x):

should go first.

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