Find a string

  • + 0 comments

    Happy with my code as it is easy to ready and digest

    def count_substring(string, sub_string):
        x = len(string)
        y = len(sub_string)
        count = 0
        for i in range(0, x):
            if sub_string == string[ i : i+y ]:
                count += 1
        return count