You are viewing a single comment's thread. Return to all comments →
easier version
def count_substring(string, sub_string): counter = 0 while sub_string in string: counter += 1 find = string.find(sub_string) string = string[find + 1:] return counter
Seems like cookies are disabled on this browser, please enable them to open this website
Find a string
You are viewing a single comment's thread. Return to all comments →
easier version
def count_substring(string, sub_string): counter = 0 while sub_string in string: counter += 1 find = string.find(sub_string) string = string[find + 1:] return counter