Advertisement
tranthetoan

Freaking break in python looop

Dec 29th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. class StringSearch():
  2.     def naiveSearch(self, text, substring):
  3.         for i in range(0, len(text) - len(substring)):  
  4.             for j in range(0, len(substring)):                
  5.                 print "text["+ str(i+j) + "]= " + text[i+j]
  6.                 print "substring[" + str(j) + "]= " + substring[j]
  7.                 if text[i +j] != substring[j]:
  8.                     break
  9.             else:
  10.                 return i
  11.         return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement