12.Printing out a list item by item in a function


#1



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


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


I do not understanf where this error come from.


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]


print_list(n)


#2

the code provided by the exercise:

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

should have been used for the function, you wrote a new loop, which is fine, but then you have to remove the loop provided by the exercise (code i posted)


#3

Thank you very much!! It solved my problem.


#4

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