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 44Domain : Python
55Author : Ahmedur Rahman Shovon
66Created : 15 July 2016
7+ Updated : 08 February 2023
78Problem : https://www.hackerrank.com/challenges/find-a-string/problem
89"""
910
1011
1112def 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
1618
17-
18- if __name__ == "__main__" :
19+ if __name__ == '__main__' :
1920 string = input ().strip ()
2021 sub_string = input ().strip ()
21-
22+
2223 count = count_substring (string , sub_string )
2324 print (count )
You can’t perform that action at this time.
0 commit comments