You are viewing a single comment's thread. Return to all comments →
def count_substring(string, sub_string): count1 = 0 count2 = 0 i=0 j=0
while(j<=len(string)-1): if string[j] == sub_string[i]: count1 += 1 if count1 == len(sub_string): count2 += 1 count1 = 0 i = 0 continue else: i+=1 j+=1 continue count1 = 0 i = 0 j += 1 return count2
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 →
def count_substring(string, sub_string): count1 = 0 count2 = 0 i=0 j=0
if name == 'main': string = input().strip() sub_string = input().strip()