# Printing out a list item by item in a function- error maximum recursion depth

#1

Continuing the discussion from 12 Printing out a list item by item in a function - error:

Hi,
Here’s a printscreen of my code with the error included. I’m not really sure how to fix this. Any help is appreciated!
<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

```python

Replace this line with your code.

``<do not remove the three backticks above>``

#2

#3
``````#Create your list
n = [3, 5, 7]

def print_list(x):
#loop until the length of the argument **x**
for i in range(0, len(x)):
#Print it out
print x[i]
print print_list(n)``````

#4

Thank you @bandit for your reply but sorry I still don’t understand. I’m now receiving a different error message from changing the indent of print print_list(n).

#5

Haha well that’s because your print print_list should be on line 10 wih a space betwen the function and you don’t need to include a print statement.

#6

@bandit I took out the print statement but it still didn’t work, so I added it back and moved print print_list to line 10. Am I having a serious dumb moment because this task has taken me the longest time to solve over anything so far, and it was supposed to be simple!

#7

There should be no indentation for `print_list(n)`

#8

Now I’m getting a different error. Sorry if I’m being frustrating!

#9

Haha no not at all! debugging code is the fun part of programming

``````n = [3, 5, 7]

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

try this code format.

#10

Problem is 2 for loops

#11

Whey it worked!! Thank you so much!

#12

If that was the answer you were looking for feel free to click the solution button beneath my reply

#13

when I use you codeI get the error:
“The body of your function should not contain references to ‘n’.”

#14

Leave an empty line between `print x[i]` and `print_list(n)`

#15

You don’t need to use two for loops. One is enough.
You also forget to return the x. Here is the working code:

``````n = [3, 5, 7]
def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] * 2
# Don't forget to return your new list!
return x

print double_list(n)``````

#16

This gives me an error.

#17