I'm returning true after a copy still i'm getting all sequences.
def subset(nums,tot):
    res=[]
    def sub_seq(curr,i,s):
        if i==len(nums):
            if s==tot:
                res.append(curr.copy())
                return True# Even I'm returning true its bot working
            return False
                
        curr.append(nums[i])
        s+=nums[i]
        sub_seq(curr,i+1,s)
                
        s-=nums[i]
        curr.pop()
        sub_seq(curr,i+1,s)
    sub_seq([],0,0)
    return res
    
print(subset([1,2,1],2))
 
                        
You're returning
True, but you're not using it to stop further processing. To do so, have the other recursive calls tosub_seqimmediately cease continued processing when the recursive call returnsTrue:Try it online!