We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4c21a05 commit 1087943Copy full SHA for 1087943
strings/find-a-string.py
@@ -0,0 +1,17 @@
1
+# https://www.hackerrank.com/challenges/find-a-string/problem
2
+
3
4
+def count_substring(string, sub_string):
5
+ count = 0
6
+ for i in range(len(string)):
7
+ if string[i] == sub_string[0]:
8
+ if string[i:(i + len(sub_string))] == sub_string:
9
+ count += 1
10
+ i += len(sub_string) - 1
11
12
+ return count
13
14
15
+string = input()
16
+sub_string = input()
17
+print(count_substring(string,sub_string))
test.py
@@ -0,0 +1,5 @@
+a = 'hello'
+b = 'hello'
+print(a == b)
+print(a[0:2] == 'he')
0 commit comments