File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 4
4
Domain : Python
5
5
Author : Ahmedur Rahman Shovon
6
6
Created : 15 July 2016
7
+ Updated : 08 February 2023
7
8
Problem : https://www.hackerrank.com/challenges/find-a-string/problem
8
9
"""
9
10
10
11
11
12
def count_substring (string , sub_string ):
12
- return sum (
13
- string [i : i + len (sub_string )] == sub_string
14
- for i in range (len (string ) - len (sub_string ) + 1 )
15
- )
13
+ count_sub_string = 0
14
+ for i in range (len (string ) - len (sub_string ) + 1 ):
15
+ if string [i : i + len (sub_string )] == sub_string :
16
+ count_sub_string += 1
17
+ return count_sub_string
16
18
17
-
18
- if __name__ == "__main__" :
19
+ if __name__ == '__main__' :
19
20
string = input ().strip ()
20
21
sub_string = input ().strip ()
21
-
22
+
22
23
count = count_substring (string , sub_string )
23
24
print (count )
You can’t perform that action at this time.
0 commit comments