-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsympali_BAT.py
More file actions
67 lines (60 loc) · 1.69 KB
/
sympali_BAT.py
File metadata and controls
67 lines (60 loc) · 1.69 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from math import*
n=int(input())
s=[]
for i in range(n):
s.append(input())
def sympali(s):
l=len(s)
f=[]
b=[]
count=0
count1=0
if l%2==0:
mid=int(l/2)
for i in range(mid):
f.append(s[i])
for i in range(mid,l):
b.append(s[i])
dupb=[]
dupb=b.copy()
b.reverse()
for i in range(len(f)):
if f[i].lower()==b[i].lower():
count=count+1
for i in range(len(f)):
if f[i].lower()==dupb[i].lower():
count1=count1+1
if count==len(f) and count1!=len(f):
print('Palindrome')
if count1==len(f) and count!=len(f):
print('Symmetric')
if count==len(f) and count1==len(f):
print('Both',count,count1)
if count!=len(f) and count1!=len(f):
print('No property')
if l%2!=0:
mid=l/2
midm=floor(mid)
for i in range(midm):
f.append(s[i])
for i in range(midm+1,l):
b.append(s[i])
dupb=[]
dupb=b.copy()
b.reverse()
for i in range(len(f)):
if f[i].lower()==b[i].lower():
count=count+1
for i in range(len(f)):
if f[i].lower()==dupb[i].lower():
count1=count1+1
if count==len(f) and count1!=len(f):
print('Palindrome')
if count1==len(f) and count!=len(f):
print('Symmetric')
if count==len(f) and count1==len(f):
print('Both')
if count!=len(f) and count1!=len(f):
print('No property')
for i in range(n):
sympali(s[i])