LIVEDSA Part1 Lapindrome

this is my python code . it runs fine in jupyter notebook but here i got runtime error or wrog answer . Please guide my .
def findordsum(a):
for i in a:
sum += ord(i)

return sum

def lapindrome(string_input):
n = len(string_input)

if n ==1 :
    return 'YES'

if n > 0:
    if n%2==0:
        first_half = findordsum(string_input[:(n//2)])
        second_half = findordsum(string_input[(n//2) :])
        first_half = findordsum(string_input[:n//2])
        second_half = findordsum(string_input[(n//2)+1 :])

if first_half == second_half:
    return 'YES'
    return 'NO'

a = int(input())
while a >0:
b = input()
c = lapindrome(b)

Can you format your code? Forum software has messed up your code.

I am also getting wrong answer on submission .
Here is the code


You need to print YES and NO not Yes or No.

Moreover you can write a more compact pythonic code using collections module as follows:

from collections import Counter

for test in range(int(input().strip())):
    string = input().strip()
    string_len = len(string)
    print(["NO", "YES"][Counter(string[: string_len >> 1]) == (Counter(string[1 + (string_len >> 1): ]) if string_len % 2 else Counter(string[string_len >> 1: ]))])