Vincent Wan wrote:
So

You were doing fine up to here...

for x in list:
    do_something_with_an_element(list[x])

and python keeps track of x for you.

Now you are back into your original mistake! It should be for x in list: do_something_with_an_element(x)

The variable in a for loop receives the actual list elements, not their indices.

BTW it's a good idea to use a name other than 'list' for your list; 'list' is actually the name of the list type.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to