# Revision history [back]

A possible approach might be the following:

vars=[]
f = 0
for counter in range(1,5):
vars.append( var('x'+str(counter) ))
f += mylist[counter] * vars[counter]


Then you can use a dictionary to evaluate. Say you have n variables and want variable i in vars to take value val[i] where val is a list of values. So first construct a dictionary with

eval_dict = dict( [ (vars[i], val[i]) for i in range(n) ] )


Then you can evaluate by executing

f( eval_dict )


A possible approach might be the following:

vars=[]
f = 0
for counter in range(1,5):
vars.append( var('x'+str(counter) ))
f += mylist[counter] * vars[counter]


Then you can use a dictionary to evaluate. Say you have n variables and want variable ivars[i] in vars to take value val[i] where val is a list of values. So first construct a dictionary with

eval_dict = dict( [ (vars[i], val[i]) for i in range(n) ] )


Then you can evaluate by executing

f( eval_dict )