Guest User

Untitled

a guest
Oct 8th, 2011
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. from string import *
  2. def countSubStringMatchExact(target, key):
  3.     ans=()
  4.     for i in range(0,len(target) + 1): # Add + 1 to the end point of the range, because the amount of indices are 1 greater than the length of a string.
  5.         duplicate = False  # This will keep track of if a duplicate is found.
  6.         if find(target,key,i) == -1:
  7.             return ans
  8.         for n in ans:  # Goes through the tuple and checks to see if the current answer is in it.
  9.             if find(target,key,i) == n:
  10.                 duplicate = True  # If it is in it, we know it's a duplicate.
  11.         if not duplicate:  # Will only add to our tuple if it isn't a duplicate.
  12.             ans += ((find(target,key,i)),)
  13.     return ans
  14.  
Advertisement
Add Comment
Please, Sign In to add comment