How to return array list as a python object?
<p>I have a method which sends a message to Facebook in <a href="https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template" rel="nofollow noreferrer">Generic template</a> .
My code:</p>

<pre><code>def send_receipt(self, fbid, title, url, img_url, summary):
    return self._send(message={
        "recipient": {
            "id": fbid
        },
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "generic",
                    "elements": [
                        {
                            "title": title,
                            "item_url": url,
                            "image_url": img_url,
                            "subtitle": summary
                        }
                    ]
                }
            }
        }
    })
</code></pre>

<p>It works fine for me, but it only returns 1 element. I want to get 2 or 3 elements from JSON, so I think that I can make it work by making an element object, and this object returns the array list.</p>

<pre><code>def send_receipt(self, fbid, elements):
    return self._send(message={
        "recipient": {
            "id": fbid
        },
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "generic",
                    "elements": elements
                }
            }
        }
    })
</code></pre>

<p>And I did make a method to return elements. But I'm new to python, so what I have done didn't work for me.</p>

<pre><code>elements = [{
            "title": title,
            "item_url": url,
            "image_url": img_url,
            "subtitle": summary }]
</code></pre>