from sympy import symbols, diff, nsolve, Symbol

x, y, L = symbols('x, y, L') #Defines the mathematical variable symbols to be used. L represents lambda, because lambda is a reserved keyword in Python.
f = x**2 + y
g = x-y

def finding_equations(f, g):

    eqs = []
    for symbol in f.atoms(Symbol): #f.atoms(Symbol) picks out the symbols that represent our variables.
        eqs.append(diff(f,symbol) - L * diff(g,symbol))

    eqs.append(g)

    return eqs

Result = nsolve(finding_equations(f, g), [x, y, L], [1,1,1]) #nsolve takes a set of equations (determined by finding_equations(f,g) and solves for the given variables. Takes at least three arguments: equations, symbols, strting estimate)
print(Result)