Weird function return value?

前端 未结 3 1049
南旧
南旧 2020-12-12 07:47

I am trying to remove everything between curly braces in a string, and trying to do that recursivesly. And I am returning x here when the recursion is over, but

3条回答
  •  攒了一身酷
    2020-12-12 08:35

    ...
    #print(x)
    doit(x,end+1)
    ...
    

    should be

    ...
    #print(x)
    return doit(x,end+1)
    ...
    

    You are missing the return statement in the if block. If the function is calls itself recursively, it doesn't return the return value of that call.

提交回复
热议问题