I have:
import sympy as sp
L1,L2,T = sp.symbols("L1,L2,T")
expr = L1 L2*T
expr.subs([(L1,2),(L2,4),(T,[1,2,3,4])])
I want to evaluate T at every value in the list [2,5,7,8] but it doesn't evaluate the list. Is there a way to do this so that each value in the list can get evaluated and get an output for each? This is what I need:
2 4*1 = 6
2 4*2 = 10
2 4*3 = 14
2 4*4 = 18
CodePudding user response:
As pointed out by hpaulj:
res = [expr.subs([(L1,2),(L2,4),(T, t)]) for t in [1,2,3,4]]
res
# out: [6, 10, 14, 18]