'How to select a component of a sympy equation?

I would like to know if it is possible to select the compotent of a given term of an equation. For example in the photo below. I got that result for a tensor component and I wanna know if it is possible for me to get only the coefficient of the term that accompanies the (e-1)^4 (without having to copy it by hand).

enter image description here



Solution 1:[1]

Use the coeff method:

>>> eq = 3*y*(1 - x)**4 + 2*y*(1 - x)
>>> eq.coeff((1-x)**4)
3*y

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 smichr