1 | initial version |
What about :
sum([u[0]*u[1] for u in f if all([(v%5)==0 for v in u[1].exponents()[0]])])
x^10*y^5
This kind of brutal one-liner isn't very readable. If you plan to use this kind of trick often, generalizing it in a cleanly written and documented function is probably a better way...
HTH,