Skip to content

Commit 5041d10

Browse files
authored
Create Find a string.py
1 parent 5609b37 commit 5041d10

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Problem: https://www.hackerrank.com/challenges/find-a-string/problem
2+
# Score: 10
3+
4+
5+
def count_substring(string, sub_string):
6+
count = 0
7+
for i in range(len(string) - len(sub_string) + 1):
8+
if string[i: i + len(sub_string)] == sub_string:
9+
count += 1
10+
return count

0 commit comments

Comments
 (0)