Python | Getting 897 instead of 790 in 763 3 7 9 9 0 -1 -1 2 1 4 3 2 5 2 2


#1
def sumNumbersUtil(root, ansList, ssf):
    if root is None:
        return
    ssf += str(root.val)
    if root.left == root.right == None:
        ansList.append(ssf)
        ssf = ssf[:-2]
    sumNumbersUtil(root.left, ansList, ssf)
    sumNumbersUtil(root.right, ansList, ssf)
    
class Solution:
    def sumNumbers(self, root):
        ansList = []
        sumNumbersUtil(root, ansList, "")
        # print(ansList)
        ans = 0
        for numStr in ansList:
            ans = (ans%1003 + (int(float(numStr))%1003)%1003)
        return ans%1003

Can anyone please help?