You are viewing a single comment's thread. Return to all comments →
Ya'll answers are complicated. I still used it for reference and this is what I came up with.
def count_substring(string, sub_string): counter = 0
for i in range(1, len(string)): if sub_string in string: find = string.find(sub_string) string = string[find + 1:] counter += 1 return counter
if name == 'main': string = input().strip() sub_string = input().strip()
count = count_substring(string, sub_string) print(count)
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 →
Ya'll answers are complicated. I still used it for reference and this is what I came up with.
def count_substring(string, sub_string): counter = 0
if name == 'main': string = input().strip() sub_string = input().strip()