Find a string

  • + 0 comments

    This is a simple solution.

    def count_substring(string, substring):
    
    times = 0
    
    for pos, char in enumerate(string):
    
        if(char == sub_string[0] and string[pos:pos + len(sub_string)] == sub_string):
            times += 1         
    
    return times