关于嵌套函数运行代码出错



```python


class solution:
    def sequ(self,low:int,high:int):

        setA = self.helper(high)
        setB = self.helper(low-1)
        for num in setB:
            if num in setA:
                setA.remove(num)
        return sorted(list(setA))

    def helper(self,x):
        mySet = set()
        def dfs(cur_num,next_digit):
            nonlocal x,mySet
            if(cur_num>x):
                return
            else:
                mySet.add(cur_num)
                if(next_digit == 10):
                    return
                dfs(cur_num*10 + next_digit,next_digit + 1)

            for i in range(1,10):
                dfs(0,i)
            return mySet

if __name__ == '__main__':
    li = solution()
    li.sequ(200,2000)

这是我调用的代码,但是无法运行,报错内容如下:
Traceback (most recent call last):
  File "D:/Program Files (x86)/anaconda/envs/learn tensorflow/tushare1.py", line 734, in <module>
    li.sequ(200,2000)
  File "D:/Program Files (x86)/anaconda/envs/learn tensorflow/tushare1.py", line 709, in sequ
    setA = set(self.helper(high))
TypeError: 'NoneType' object is not iterable

1,是不是setA的设置出错了。
2, helper函数是不是分别被high,和low调用了两次。

你的helper函数实际上只执行了:

mySet = set()
return None

这两句,dfs根本没有被调用

你的helper函数没有返回值呀



```python
class solution:
    def sequ(self,low:int,high:int):
        setA = self.helper(high)
        setB = self.helper(low-1)
        for num in setB:
            if num in setA:
                setA.remove(num)
        return sorted(list(setA))
    def helper(self,x):
        mySet = set()
        def dfs(cur_num,next_digit):
            nonlocal x,mySet
            if(cur_num>x):
                return
            else:
                mySet.add(cur_num)
                if(next_digit == 10):
                    return
                dfs(cur_num*10 + next_digit,next_digit + 1)
        for i in range(1,10):
            dfs(0,i)
        return mySet

```
把for 循环那里缩进就好了,谢谢你的提醒。