count substring python code example
Example: python substring count
def count_substring(string, sub_string):
c = 0
while sub_string in string:
c += 1
string = string[string.find(sub_string)+1:]
return c
def count_substring(string, sub_string):
c = 0
while sub_string in string:
c += 1
string = string[string.find(sub_string)+1:]
return c