From 37f1efca4da92d2629a479a434875e8a342fb242 Mon Sep 17 00:00:00 2001 From: Lukas Baumann Date: Thu, 18 Feb 2021 10:23:16 +0100 Subject: [PATCH] Create 2 - Substring Counting.py --- 8/2 - Substring Counting.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 8/2 - Substring Counting.py diff --git a/8/2 - Substring Counting.py b/8/2 - Substring Counting.py new file mode 100644 index 0000000..48fbe83 --- /dev/null +++ b/8/2 - Substring Counting.py @@ -0,0 +1,8 @@ +needle = input() +haystack = input() +x = 0 +for i in range(len(haystack)-len(needle) + 1): + if haystack[:len(needle)] == needle: + x += 1 + haystack = haystack[1:] +print(x)