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.