Skip to content

Commit 62c7093

Browse files
authored
kept easy to understand code
1 parent 879ca6c commit 62c7093

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Strings/Findastring.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
66
Created : 15 July 2016
7+
Updated : 08 February 2023
78
Problem : https://www.hackerrank.com/challenges/find-a-string/problem
89
"""
910

1011

1112
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
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)

0 commit comments

Comments
 (0)