def count_substring(string, sub_string): c = 0 while sub_string in string: c += 1 string = string[string.find(sub_string)+1:] return c