Ask Your Question

Revision history [back]

You can use list comprehension and the fact that symbolic expressions have a degree method as follows:

sage: L = [3*x+2, 4*x^3, x+x^2, SR(2)]
sage: [i for i in L if 1 <= i.degree(x) <= 2]
[3*x + 2, x^2 + x]