### How to separate a symbolic expression into sub expressions

I want to separate a symbolic expression into two sub-expressions, one sub-expression with a certain variable and the other without the variable.

*The following example was revised to better demonstrate what I want to achieve*

For example, with the following function, ~~f,~~f,

```
var('x,y,z')
f=cos(x)*e^(cos(x))*(3*y+z)^2
```

I want to obtain two sub-expressions as

```
f1=cos(x)*e^(cos(x))
f2=(3*y+z)^2
```