Below is my list
l =['[37i9dQZF1DX5, 37i9dQZF1DWTR, 37i9dQZF1DX0s5]']
I want to convert it into
l =[37i9dQZF1DX5, 37i9dQZF1DWTR, 37i9dQZF1DX0s5]
I tried using eval but it doesn't work!
Below is my list
l =['[37i9dQZF1DX5, 37i9dQZF1DWTR, 37i9dQZF1DX0s5]']
I want to convert it into
l =[37i9dQZF1DX5, 37i9dQZF1DWTR, 37i9dQZF1DX0s5]
I tried using eval but it doesn't work!
You ca do this,
l =['[37i9dQZF1DX5, 37i9dQZF1DWTR, 37i9dQZF1DX0s5]']
l2 = l[0].replace("[","").replace("]","").split(", ")
Which will give you the following as the content of l2
['37i9dQZF1DX5', '37i9dQZF1DWTR', '37i9dQZF1DX0s5']
If the contents of the list are strings, you can use json
import json
l = '["37i9dQZF1DX5", "37i9dQZF1DWTR", "37i9dQZF1DX0s5"]'#I added " to make strings
print (json.loads (l))
type (json.loads (l))
The output will be:
["37i9dQZF1DX5", "37i9dQZF1DWTR", "37i9dQZF1DX0s5"]
<class 'list'>