Printing out a list item by item in a function - Error


#1



Printing out a list item by item in a function

Can someone help with this, please?
I get this error: Oops, try again. Your function caused the following error: maximum recursion depth exceeded while calling a Python object.
What does that exactly mean?


Replace this line with your code. 
n = [3, 5, 7]
def print_list(x):
  for i in range(0, len(x)):
    print x[i]
    return print_list(n)


#2

Indentation places the return inside the loop so it iterates only once before exiting the function.


#3

Ok, so it means I should change the indentation, right?


#4

n = [3, 5, 7]
def print_list(x):
(ind) for i in range(0, len(x)):
(ind 2) print x[i]
(the same line as def) print_list(n)

thank you:)


#5

Yes, have it line up with the for.


#6

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