MCPcopy Create free account
hub / github.com/Avisikta-Majumdar/HackerRank_Python_Solutions / count_substring

Function count_substring

Find a string.py:1–10  ·  view source on GitHub ↗
(string, sub_string)

Source from the content-addressed store, hash-verified

1def count_substring(string, sub_string):
2 len_SubString= len(sub_string)
3 result = 0
4 for i in range(len(string)+1-len_SubString):
5 if string[i:i+len_SubString]==sub_string:
6 result+=1
7 else:
8 continue
9
10 return result
11
12if __name__ == '__main__':
13 string = input().strip()

Callers 1

Find a string.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected