1 2 3 4 5 6 7 8 9 10
from string import * def countSubStringMatch(target, key): """iteratively counts the number of instances of the key in the target string""" zz = find(target,key) num = 0 while zz!=-1: num = num + 1 zz = find(target,key,zz+1) return num