On 22/11/11 05:28, John wrote:
def survivor(names, step):
index = step - 1
next = names
while len(next)> 1:
next.remove (next[index])
However when ever i run it i get this error message:
next.remove (next[index])
IndexError: list index out of range
Any ideas about whats causing this error?
You are doing the programming equivalent of sitting on the branch of a
tree and cutting 2 feet off the end of the branch. But you never move
your position so eventually you cut off the section of branch you are
sitting on...
You never change index so eventually you remove enough of next that
theres no longer any data at index.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor