[Tutor] Splitting a string

tee chwee liong tcl76 at hotmail.com
Tue Feb 8 14:04:17 CET 2011


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 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110208/0a23e78c/attachment-0001.html>


More information about the Tutor mailing list