title: How can I concatenate a string using Jinja for loop?
body: <p>I am trying to iteratively concatenate a string to build url params with a 'for' loop, but I believe I am having scoping issues. </p>
  
  <pre><code>The output should be: url_param = "&amp;query_param=hello&amp;query_param=world"
  
  array_of_objects = [{'id':'hello'},{'id':'world'}]
  
  {% set url_param = "" %}
  
  {% set array_of_ids = array_of_objects|map(attribute='id')|list%} // correctly returns [1,2]
  
  {% for id in array_of_ids %}
     {% set param = '&amp;query_param='~id %}
     {% set url_param = url_param~param %}                             
  {% endfor %}
  
  //url_param is still an empty string
  </code></pre>
  
  <p>I also tried namespace(), but to no avail:</p>
  
  <pre><code>{% set ns = namespace() %}
   {% set ns.output = '' %}
   {% set array_of_ids = array_of_objects|map(attribute='id')|list%} // correctly returns [1,2]
  {% for id in array_of_ids %}
     {% set param = '&amp;industries='~id%}
     {% set ns.output = ns.output~param %}                             
  {% endfor %}
  //ns.output returns namespace
  </code></pre>