Find a string

  • + 0 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..