-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsub.py
33 lines (32 loc) · 816 Bytes
/
sub.py
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
32
33
"""this project about find a certain string or sub string in a string"""
import _string
z=[]
def func(x,y,i):
print(z)
w=y.find(x)
print(w)
if w == -1:
return z
else:
z.append(w+i)
"""print(z)"""
index=len(z)
i=z[index-1]+len(x)
func(x,y[i:],i)
while(1):
try:
y=input("enter the full string: ")
x=input("enter the sub string: ")
if x == "" or y == "":
print("Enter a valid string please!")
quit()
x=x.strip()
y=y.strip()
w=func(x,y,0)
if w == -1 or w== []:
print("the sub strint not found")
else:
print("the substring founded its at the positions: "+str(z))
z=[]
except Exception as e:
print("Error ! "+str(e))