Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Count Substring Occurrences by tokiojapan55
def count_occurrences(main_str: str, sub_str: str) -> int:
i, ans = -1, 0
while (i := main_str.lower().find(sub_str.lower(), i + 1)) >= 0:
ans += 1
return ans
Nov. 21, 2023