I have an expression as follows:
from sympy import *
x = symbols('x')
ex = 2+2*x
I would like to factor out -2 from the expression. I have tried to factor using the .factor() method and this is what I got:
ex.factor()
>>> 2*(x + 1)
How can I explicitly set the factor I would like to use in sympy?