Create 2 - Substring Counting.py

This commit is contained in:
Lukas Baumann 2021-02-18 10:23:16 +01:00 committed by GitHub
parent 4195fcf9e2
commit 37f1efca4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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