Printing out a list item by item in a function


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]


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).


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