def f(x, values_dct, eq_lst):
    """
    Solves equations in eq_lst for x, substitutes values from values_dct, 
    and returns value of x.
    :param x: Sympy symbol
    :param values_dct: Dict with sympy symbols as keys, and numbers as values.
    """
lst = []
lst += eq_lst
for i, j in list(values_dct.items()):
    lst.append(sp.Eq(i, j))
try:
    return sp.solve(lst)[0][x]
except IndexError:
    print('This equation has no solutions.')
Pythonic way to manage arbitrary amount of variables, used for equation solving.