0 out of 464 challenges solved
Write a Python function `count_occurrences` that counts the number of times the substring `'std'` appears in a given string. The function should be case-sensitive and only count non-overlapping occurrences. #### Example Usage ```python [main.nopy] print(count_occurrences("letstdlenstdporstd")) # Output: 3 print(count_occurrences("truststdsolensporsd")) # Output: 1 print(count_occurrences("makestdsostdworthit")) # Output: 2 print(count_occurrences("stds")) # Output: 1 print(count_occurrences("")) # Output: 0 ```
def count_occurrences(s: str) -> int: """ Count the number of occurrences of the substring 'std' in the given string. Args: s (str): The input string. Returns: int: The count of 'std' occurrences. """ # Initialize a counter for occurrences count = 0 # Iterate through the string to find 'std' # Placeholder for implementation return count