Printing out a list item by item in a function


#1



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


Can somebody explain why I can't print out the elements in the list in this way:


def print_list(x):
    for i in x:
        print x[i]
print_list(n)


#2

because i contains values from the list, not indexes. What you do would assume i are indexes, this would require to use range() in your for loop


#3

Perfect, thanks very much for the explanation!


#4