Printing out a list item by item in a function error


Error that I am getting:
Oops, try again. The body of your function should not contain any references to 'n'

I don't know what is the meaning of that error and why I am getting that error, what is problem with my code?
This is my code:

n = [3, 5, 7]

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

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


Printing out a list item by item in a function

this for loop:

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

was provided by the exercise to place inside your function and modify. You made a new loop, that is fine, but then you should remove the loop which is outside the function


Yes, it solved my problem, thank you very much.

But I think that should not cause the problem in the first place and the
loop I created had nothing to do with the reference to 'n' as the error
message was showing. All I am saying is that leaving the original loop
there as it is should not be a cause of error in that exercise.

But, after removing the pre placed loop as you suggested, the problem was
solved. Thank you for that.


the instruction do say to use that loop as scaffold, anyway, i am just helping out people on the forum, if you think there is a problem, you can report a bug


Yes, you are right, I didn't pay attention to that, anyway thanks to you I
got it right.