title: Creating a dynamic JSON using a python list
body: <p>This is the json structure that I am having inside of a python file. Here the stationList_of_state is a python list which has some 5-10 values which will change dynamically based on the code.</p>
  <pre><code>        message = {
          &quot;type&quot;: &quot;template&quot;,
          &quot;payload&quot;: {
              &quot;template_type&quot;: &quot;generic&quot;,
              &quot;elements&quot;: 
              [
                  {
                      &quot;buttons&quot;: [
                              {
                                  &quot;title&quot;: stationList_of_state[1],
                                  &quot;payload&quot;: stationList_of_state[1],
                                  &quot;type&quot;: &quot;postback&quot;
                              }
                          ]
                      }
                  ]
              }
          }
  </code></pre>
  <p>I have tried something like this which showed errors:</p>
  <pre><code>        message = {
              &quot;type&quot;: &quot;template&quot;,
              &quot;payload&quot;: {
                  &quot;template_type&quot;: &quot;generic&quot;,
                  &quot;elements&quot;: 
                  [
                  for i in range(len(stationList_of_state)):
                      {
                          &quot;buttons&quot;: [
                                  {
                                      &quot;title&quot;: stationList_of_state[i],
                                      &quot;payload&quot;: stationList_of_state[i],
                                      &quot;type&quot;: &quot;postback&quot;
                                  }
                              ]
                          }
                      ]
                  }
              }
  
  </code></pre>
  <p>Can someone suggest an alternate approach to what I have did?</p>