python | recursion | easy
\nclass Solution:\n    def digitSum(self, s: str, k: int) -> str:\n        if len(s)<=k:\n            return s\n        def digitsm(s):\n            sm=0\n     
```\nclass Solution:\n    def digitSum(self, s: str, k: int) -> str:\n        if len(s)<=k:\n            return s\n        def digitsm(s):\n            sm=0\n            for i in range(len(s)):\n                sm+=int(s[i])\n            return sm\n        string=\'\'\n        for i in range(0,len(s),k):\n            try:\n                string+=str(digitsm(s[i:i+k]))\n            except:\n                string+=str(digitsm(s[i:]))\n        if len(string)<=k:\n            return string\n        return self.digitSum(string,k)\n                    \n```
[]