Can you tell me how to remove the comma at the end of the line?
Final output:
{name: "name1", My country = "region1a", My country = "region1b"},
{name: "name2", My country = "region2a", My country = "region2b"},
you only need to delete one (highlighted) comma at the end of the second line. The output is generated in this way
{% for country in AllСountry %}
{name: "{{ country }}",{% for count in lookup('vars', country) %} My country = "{{ count }}",{% if loop.last %} My country = "{{ count }}"{% endif %}{% endfor %}},
{% endfor %}
as a result, we need this output
{name: "name1", My country = "region1a", My country = "region1b"},
{name: "name2", My country = "region2a", My country = "region2b"}