keys_in_target = []
def countSubStringMatchRecursive(target, key, count = 0): #Recursive function that counts instances of key in target
# by modifying the target string to include only the letters
# after the point where the key was previously found.
location = target.find(key) # Finds location of key in target.
if location != -1:
count += 1 # Checks to see if key was found.
keys_in_target.append(target[location:location+len(key)]) # places key in global list.
return countSubStringMatchRecursive(target[location + len(key):], key, count) # modifies target string to include
#only portion of string after point
#key was found in previous step.
else: print 'The number of times', key, 'is in the target string', 'is:', count
# When key is not found to be contained in string, prints the length of the list of keys.
countSubStringMatchRecursive('aabbccddeeffggaabbccddeeffggaabbccaaddggdddeeaaddggaabbadddgeagdkeiabbaa', 'aa')