Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
main[i:].startswith(sub) solution in Clear category for Count Substring Occurrences by Phil15
def count_occurrences(main: str, sub: str) -> int:
main, sub = main.lower(), sub.lower()
return sum(main[i:].startswith(sub) for i in range(len(main) - len(sub) + 1))
Oct. 7, 2023
Comments: