You are viewing a single comment's thread. Return to all comments →
def count_substring(string, sub_string): c=s=0 while True: s=string.find(sub_string,s) if s==-1: break c+=1 s+=1 return c
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): c=s=0 while True: s=string.find(sub_string,s) if s==-1: break c+=1 s+=1 return c