Skip to content

Commit 9bcde74

Browse files
Add files via upload
1 parent f4676a4 commit 9bcde74

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Substring_pattern.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
a = input("Enter String: ")
2+
substr = {}
3+
patstr = {}
4+
for i in range(len(a)):
5+
n = a[i:len(a):2]
6+
substr[f'substr_{i}'] = n
7+
for key, value in substr.items():
8+
print(f"{key}: {value}")
9+
for key, n in substr.items():
10+
patstr[key] = []
11+
for j in range(len(n) - 1):
12+
if n[j] == n[j + 1]:
13+
14+
patstr[key].append(1)
15+
patstr[key].append(1)
16+
else:
17+
patstr[key].append(0)
18+
19+
20+
21+
if len(n) > 0:
22+
patstr[key].append(0)
23+
24+
print(f"Pattern for {key}{patstr[key]}")

0 commit comments

Comments
 (0)