[Tutor] Splitting a string
ALAN GAULD
alan.gauld at btinternet.com
Wed Feb 9 09:55:04 CET 2011
####
>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
>#####
>
>the enumerate is checking from left to right. is it possible check from right to
>left?
>
>for eg:s='00101'
>The easiest way is just to reverse the string:
for i,c in enumerate(reversed(s)):
HTH,
Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110209/a48952fb/attachment-0001.html>
More information about the Tutor
mailing list