Python: Value of dictionary is list of strings
<pre><code>reclist="\"MOBEEVHDBBYSQFC8\",\"MOBE9J587QGMXBB7\""
print reclist
data= {
   "ids": [
      reclist #"MOBEEVHDBBYSQFC8","MOBE9J587QGMXBB7"
   ]
}
print data
</code></pre>

<p>Output: `</p>

<pre><code>"MOBEEVHDBBYSQFC8","MOBE9J587QGMXBB7"`

{'ids': [' "MOBEEVHDBBYSQFC8","MOBE9J587QGMXBB7" ']}
</code></pre>

<p>But expecting output is:</p>

<pre><code>"MOBEEVHDBBYSQFC8","MOBE9J587QGMXBB7"
{'ids': ["MOBEEVHDBBYSQFC8","MOBE9J587QGMXBB7"]}
</code></pre>

<p>When I print <code>rectlist</code>, it did not shows extra ' ', but when I used <code>reclist</code> in <code>data</code>, then due to extra ' ' in <code>reclist</code>, showing error <code>urllib2.HTTPError: HTTP Error 400: Bad Request</code>, as I have to add this data to <code>urllib2.Request</code>.How to strip out extra ' ' from <code>reclist</code> when used in data?</p>

<p><code>reclist</code> is a string not an iterable, you can use <code>ast.literal_eval</code> in order to convert it to a tuple directly:</p>

<pre><code>In [60]: import ast

In [61]: reclist="\"MOBEEVHDBBYSQFC8\",\"MOBE9J587QGMXBB7\""

In [62]: ast.literal_eval(reclist)
Out[62]: ('MOBEEVHDBBYSQFC8', 'MOBE9J587QGMXBB7')
</code></pre>

python dictionary