You are viewing a single comment's thread. Return to all comments →
def count_substring(string, sub_string): count = 0 next_index = 0 while True: found_index = string.find(sub_string, next_index) if found_index >= 0: count += 1 next_index = found_index + 1 else: return count
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Find a string
You are viewing a single comment's thread. Return to all comments →