Error while accessing an associative array Here is the code:

{% if entry_name not in data and entry_total &gt; 0 %}
    {% set data = data|merge({ (entry_name) : entry_total }) %}
{% else %}
    {% set data.entry_name = 10 %}
{% endif %}


Twig throws an error on the statement following else condition.  Unexpected token "punctuation" of value "." ("end of statement block" expected). How can I set the value of a particular element of this associative array?
There's not a pretty way to do it in Twig other than what you've done in the if part of your conditional.  Something like this should work:

{% if attribute(data, entry_name) is not defined and entry_total &gt; 0 %}
    {% set data = data|merge({ (entry_name) : entry_total }) %}
{% else %}
    {% set data = data|merge({ (entry_name): 10 }) %}
{% endif %}