#1 by PatrickT
Good afternoon,
I have defined my vars_for_template like so:
multiplier=group.Group_multiplier
effort_cost=C.EFFORT_COST
endowment=C.ENDOWMENT
contribution=player.Contribution
return_dict=dict()
for x in range(1,8):
for y in range(x,8):
key_name=f"{x}_{y}"
value=multiplier*x-effort_cost*y+endowment-contribution
return_dict[key_name]=value
print(return_dict)
return return_dict
The dictionary is successfully filled and I can see this in my python console. However, I cannot manage to get any of the variables to come up in my HTML page. For example, A key of '1_1' corresponded to a value of 1.4 in my latest test, but in my html code {{1_1}} or {{'1-1'}} just displays 11. Any help would be appreciated. I suspect the issue is the result of my keys being strings, but I am not sure how to fix it.
Here is an example dictionary from my python console:
{'1_1': 1.4, '1_2': 1.2999999999999998, '1_3': 1.2000000000000002, '1_4': 1.1, '1_5': 1.0, '1_6': 0.8999999999999999, '1_7': 0.7999999999999998, '2_2': 1.7999999999999998, '2_3': 1.7000000000000002, '2_4': 1.6, '2_5': 1.5, '2_6': 1.4, '2_7': 1.2999999999999998, '3_3': 2.2, '3_4': 2.1, '3_5': 2.0, '3_6': 1.9, '3_7': 1.7999999999999998, '4_4': 2.6, '4_5': 2.5, '4_6': 2.4, '4_7': 2.3, '5_5': 3.0, '5_6': 2.9, '5_7': 2.8, '6_6': 3.4000000000000004, '6_7': 3.3, '7_7': 3.8}
#2 by PatrickT
The only solution, which I just figure out after making this post, was to change my f key naming strategy. I changed it to the following, and it works now when I call {{1vs1}}.
multiplier=group.Group_multiplier
effort_cost=C.EFFORT_COST
endowment=C.ENDOWMENT
contribution=player.Contribution
return_dict=dict()
for x in range(1,8):
for y in range(x,8):
key_name=f"{x}vs{y}"
value=multiplier*x-effort_cost*y+endowment-contribution
return_dict[key_name]=value
return return_dict