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


#1



Hi everybody, I've got stuck in this python program


https://www.codecademy.com/en/courses/python-beginner-nzzVa/3/1

I'm getting the error:
"Oops, try again. The body of your function should not contain any references to 'n' "

My code is as below


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)


Please help me !!!


#2

Why are you using this part?

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

This is what your function is supposed to do anyway.


#3

Thanks a lot.It sovled the problem


#4

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