[Tutor] Splitting a string
tee chwee liong
tcl76 at hotmail.com
Wed Feb 9 01:32:05 CET 2011
> `while i < len(c)` instead of `while 1`
>
hi,
i modified codes to be i<len(c) but it still goes into the except part. tq
c=('01101')
i=-1
try:
while i<len(c):
i=c.index('0',i+1)
print "Lane fail",i
except ValueError:
print "All Lanes PASS"
pass
Result:
>>>
Lane fail 0
Lane fail 3
All Lanes PASS
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110209/a9ae5663/attachment.html>
More information about the Tutor
mailing list