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
x
... #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.
return