What\'s the best way to count the number of occurrences of a given string, including overlap in Python? This is one way:
def function(string, str_to_search_f
If you want to count permutation counts of length 5 (adjust if wanted for different lengths):
def MerCount(s): for i in xrange(len(s)-4): d[s[i:i+5]] += 1 return d