You are viewing a single comment's thread. Return to all comments →
def count_substring(string, sub_string): tot = 0 i = string.find(sub_string) if(i >= 0): tot += 1 if(i == -1): return tot else: while(i != -1): i = string.find(sub_string, i+1) if(i == -1): break else: tot += 1 return tot
Mam check this logic once please..
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): tot = 0 i = string.find(sub_string) if(i >= 0): tot += 1 if(i == -1): return tot else: while(i != -1): i = string.find(sub_string, i+1) if(i == -1): break else: tot += 1 return tot
Mam check this logic once please..