Suma wszystkich podłoża liczby

Dp solution:
def sumSubstrings(self,s):
        n = len(s)
        dp = [0] * (n)
        dp[0] = int(s[0])
        res = int(s[0])
        for i in range(1, n):
            dp[i] = (i+1) * int(s[i]) + 10 * (dp[i-1])
            res += dp[i]
        return res % (10**9+7)
Helper