-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfindAString.py
More file actions
32 lines (28 loc) · 818 Bytes
/
findAString.py
File metadata and controls
32 lines (28 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
string = "WoW!TestCaseTestCase"
substring = "CaseT"
str1 = ""
# find index 1 of substring
substring_index = substring[0]
substring_length = len(substring)
if substring in string:
c = string.index(substring)
counter = c
match_count = 0
while counter < len(string)-1:
if string[counter] == substring_index:
c_ = 0
for i in range(0,substring_length):
try:
str1 += string[counter + c_]
except:
str1 = ""
if len(str1) == substring_length and str1 == substring:
print(counter)
print("found", str1)
match_count += 1
c_ += 1
str1 = ""
counter += 1
else:
match_count = 0
print(match_count)