Question: ```
   finalKeywords = [] 
   #after populating finalKeywords 
   query = {
       "apiKey" : self.apikey,
        "country" : country,
        "currency" : currency,
        "kw" : finalKeywords,
        "t" : int(time.time())
    }
    uri = urllib.urlencode(query, True)
    print uri

```

After decoding uri I get 

```
country=&apiKey=5f0092f1777c3a5ed0de&kw=iphone&kw=android&t=1496924489&currency=usd

```

While my expected output is

```
country=&apiKey=5f0092f1777c3a5ed0de&kw[0]=iphone&kw[1]=android&t=1496924489&currency=usd

```

What to do..? I have been looking for solutions but unable to get.

Answer: 
Like this?

```
query = {
       "apiKey" : self.apikey,
        "country" : country,
        "currency" : currency,
        "kw[]" : finalKeywords,
        "t" : int(time.time())
    }

```

If you need to have the positional values in there as well for some reason, this is one way to do it:

```
query = {
        "apiKey" : self.apikey,
        "country" : country,
        "currency" : currency,
        "t" : int(time.time())
    }
for p,q in enumerate(finalKeywords):
   query["kw[{pos}]".format(pos=p)] = q

```
Based on [the W3C spec for URLs](https://www.w3.org/Addressing/URL/url-spec.html#z113), `[` and `]` aren't valid in the search string, and so will be escaped by `urlencode`. With that caveat, you can construct a dictionary with unique keys by using a dictionary comprehension:

```
kw_dict = { "kw[{}]".format(n): finalKeywords[n] for n in range(0, len(finalKeywords)) }

```

You can then add this to the other parts of your query as follows:

```
query = dict({
    "apiKey" : self.apikey,
    "country" : country,
    "currency" : currency,
    "t" : int(time.time())
}, **kw_dict)

```