I have the following list in Python:
['[0,0]', '[0,1]', '[1,0]', '[1,1]']
How can I remove the apostrophes around each list item?
Thanks.
I have the following list in Python:
['[0,0]', '[0,1]', '[1,0]', '[1,1]']
How can I remove the apostrophes around each list item?
Thanks.
Use eval
carefully:
>>> [eval(l) for l in lst]
[[0, 0], [0, 1], [1, 0], [1, 1]]
Or json.loads
:
import json
>>> [json.loads(l) for l in lst]
[[0, 0], [0, 1], [1, 0], [1, 1]]