On 08/02/2011 15:04, tee chwee liong wrote:
hi all,
thanks for the advice. i modified my code to be:
c=('01101')
i=-1
try:
while 1:
i=c.index('0',i+1)
print "Lane fail",i
except ValueError:
print "All Lanes PASS"
pass
when i run, the result is:
>>>
Lane fail 0
Lane fail 3
All Lanes PASS
Question: How do i prevent the code from executing the except
ValueError part. it seems to be checking bit by bit and when is see 1
it will execute the except part.
i just want the results to be:
>>>
Lane fail 0
Lane fail 3
thanks
tcl76
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
`while i < len(c)` instead of `while 1`
--
Kind Regards,
Christian Witts
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor