title: `for` loop to avoid writing same thing multiple times
body: <pre class="lang-cpp prettyprint-override"><code>
      const double weight1{result[&quot;w_group_1&quot;]};
      std::string weight_bar1;
      GetData(weight1, weight_bar1);
      weight_bar1 += &quot; &quot;;  
  
      const double weight2{result[&quot;w_group_2&quot;]};
      std::string weight_bar2;
      GetData(weight2, weight_bar2);
      weight_bar2 += &quot; &quot;;  
      
      const double weight3{result[&quot;w_group_3&quot;]};
      std::string weight_bar3;
      GetData(weight3, weight_bar3);
      weight_bar3 += &quot; &quot;;  
  </code></pre>
  <p>How to avoid writing same thing 3 times with different numbers? If it was a variable in some calculation which has some min and max, I could have used simple <code>for</code> loop. But this is different.</p>