[Tutor] Splitting a string
tee chwee liong
tcl76 at hotmail.com
Wed Feb 9 02:56:06 CET 2011
hi all,
the code works:
####
s='00101'
found = False
for i,c in enumerate(s):
if c == '0':
print 'Lane fail',i
found = True
if not found: print 'All lanes PASS
#####
Result:
>>>
Lane fail 0
Lane fail 1
Lane fail 3
>>>
the enumerate is checking from left to right. is it possible check from right to left?
for eg:s='00101'
Will give below result:
Lane fail 1
Lane fail 3
Lane fail 4
thanks
tcl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110209/9efeb91e/attachment.html>
More information about the Tutor
mailing list