Printing out a list item by item in a function


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]


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


Perfect, thanks very much for the explanation!