-3

I was wondering if there was any way I could get the symbolic solution for a variable in an equation using python, as I've been looking around but didn't find exactly what I wanted. What I intend to do is, for example, given:

eq = x + y + 5

I'd like to get:

x = - 5 - y

BlackFog
  • 1
  • 3

1 Answers1

0
from sympy import *
x, y = symbols('x, y')
expr = x + y + 5
solve(expr, x)
>>>Out: [-5-y]
zoldxk
  • 2,632
  • 1
  • 7
  • 29
  • That was it! I checked solve(), but didn't saw any case like this and I couldn't try it right now, so thank you! – BlackFog Apr 16 '21 at 18:26