# Help with A Python Problem? Stuck from 4 hours!?

guys i need help with a code

I have been trying to solve a problem

LAPINDROME

``````   n = int(input())
while(n!=0):
x = input()
flag =0
len1 = len(x)
if(len1%2 != 0 ):
len1 = int(len1 /2)
dict1 = {}
dict2 = {}
list1 = []
list2 = []
for i in range(0,len1):
list1.append(x[i])
for i in range(len1+1,len(x)):
list2.append(x[i])
for i in range(0,len(list1)):
count = 1
for j in range(0,len(list1)):
if(i != j and list1[i] == list1[j]):
count+= 1
dict1[list1[i]] = count
for i in range(0,len(list2)):
count = 1
for j in range(0,len(list2)):
if(i != j and [i] == list2[j]):
count+= 1
dict2[list2[i]] = count
for key,value in dict1.items():
count2 = 0
for i,j in dict2.items():
if(key == i):
if(value != j):
flag = 1
else:
count2 += 1
if(count2 == len(dict1)):
flag = 1
else:
len1 = int(len1 /2)
dict1 = {}
dict2 = {}
list1 = []
list2 = []

for i in range(0,len1):
list1.append(x[i])
for i in range(len1,len(x)):
list2.append(x[i])
for i in range(0,len(list1)):
count = 1
for j in range(0,len(list1)):
if(i != j and list1[i] == list1[j]):
count+= 1
dict1[list1[i]] = count
for i in range(0,len(list2)):
count = 1
for j in range(0,len(list2)):
if(i != j and [i] == list2[j]):
count+= 1
dict2[list2[i]] = count

for key,value in dict1.items():
count2 = 0
for i,j in dict2.items():
if(key == i):
if(value != j):
flag = 1
else:
count2 += 1
if(count2 == len(dict1)):
flag = 1

if(flag == 1):
print('NO')
else:
print('YES')

n-=1``````

This is a very simple problem as it contains the tag “cakewalk”, with python it should have been even simpler with good built-in methods, instead of seeing it as a python problem, consider what is that you need to do to solve the problem and then try to map that to code.

Don’t hurt yourself, sometimes it’s better to read the editorial and come up with a solution yourself,

from your solution it seems you are over complicating things here.
Here’s what you need to do

``````          `find the length of the str :
check whether it is even or odd :
if even:
split into two equal parts
else:
split by ignoring the middle value
now sort and compare
if equal print "yes"
else "no" `
``````

have fun while solving, else skip it, it’s not the end of the world.