def eval_sum(parse_result):
 total = 0.0
 current_op = operator.add
 for token in parse_result:
  if (token == '+'):
   current_op = operator.add
  elif (token == '-'):
   current_op = operator.sub
  else:
   total = current_op(total, token)
 return total

def eval_sum ( parse_result ) : total = 0.0 current_op = operator . add for token in parse_result : if ( token == '+' ) : current_op = operator . add elif ( token == '-' ) : current_op = operator . sub else : total = current_op ( total , token ) return total
add the inputs .