Printing out a list item by item in a function


#1


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

Hi
I need some help with this exercise please
This is the error message:
Your function caused the following error: list index out of range


n = [3, 5, 7]


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


#2

You need to loop over the range of 0 to length of the parameter, not the variable;

for i in range(0, len(x)): //len(x) (parameter), not len(n) (variable).

#3

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