"Laurens Vets" <laur...@daemon.be> wrote
next to each other. I came up with the following (Please ignore the
fact that I'm trying to avoid an IndexError in a stupid way :)):
Others have answered your question.
I'll suggest that instead of using indexes its easier to just cache
the
last two values in variables - back1 and back2 say.
initialise them to values outside the range for the first two values
then the loop body becomes (in pseudo code)
x = random number
if x == back1 == back2: # a triple
print 'error'
else
back2,back1 = back1,x
append(x)
HTH,
Alan G.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor