-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab7.3.py
More file actions
45 lines (38 loc) · 791 Bytes
/
Lab7.3.py
File metadata and controls
45 lines (38 loc) · 791 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
string = input("Text: ")
def isClosure(c):
if c=='(':
return True
elif c==')':
return True
elif c==']':
return True
elif c=='[':
return True
elif c=='}':
return True
elif c=='{':
return True
else:
return False
Closures ={
'(':')',
'[':']',
'{':'}'
}
def Remove(string):
if(len(string)%2 == 1):
return False
while(string!=""):
print(string)
i = 0
for i in range(0,len(string)):
if(Closures[string[i]]==string[i + 1]):
break
else:
break
string = string[:i] + string[i + 2:]
else:
return True
return False
string = ''.join(c for c in string if isClosure(c))
print(Remove(string))