EVENTUAL JULY COOKOFF 2020

    
def checkcount(strr):
    d={}
    for i in strr:
        if(i in d):
            d[i]=d[i]+1
        else:
            d[i]=1
        
    for i in d:
        if(d[i]%2!=0):
            return False
        return True
def checkempty(string):
    if(len(string)==0):
        return True
    s=string[::-1]
    if(s==string):
        if(len(string)%2==0):
            return True
        return False
    if(len(string)%2==0):
        g=string
        ans1=checkcount(g)
        if(ans1):
            return True
        return False

        
    else:
        return False
lst=[]        
a=int(input())
for i in range(a):
    b=int(input())
    c=input()
    lst.append(c)
for i in lst:        
    ans=checkempty(i)
    if(ans):
        print("YES")
    else:
        print("NO")

For the given test cases this code was running fine but when i submmited the submission was unsuccessful. can someone tell what is the error in the logic??

I am providing link of my solution just take outputs of random input then try to debug. I think debugging your own solution is a way to improve
here is linkEventual

Hello @rahul10398, explain your code/approach so that everyone can understand. Btw, this is my solution. it’s the same approach I guess. Feel free to ask if anything is unclear.

i figured out the error. actually i was returing true inside for loop in checkcount function. when i corrected it test cases passed. silly mistake