Hey, I'm wondering...
In 12. Printing out a list item by item in a function...
How come you have to write range() at all? Why doesn't
for i in x work? i.e.:
n = [3, 5, 7] def print_list(x): for i in x: print x[i] print_list(n)
It throws the following error:
Traceback (most recent call last):
File "python", line 7, in
File "python", line 5, in print_list
IndexError: list index out of range
In previous lessons like A Day at the Supermarket this wasn't the case: