hacker rank python problem (find a string)

FIND A STRING


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


Compiler Message
Success
Input (stdin)Download
ABCDCDC
CDC
Expected OutputDownload
2

Comments

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions