Python - Convert stringified list back to list

10.4k views Asked by At

I have a stringified list:

a = ['one', 'two']
a = str(a)

After which, a would be

"['one', 'two']"

Is there a way to go from this string format back to a list like the original format?

Thanks

1

There are 1 answers

2
sachin saxena On BEST ANSWER

use eval :

a = eval("['one', 'two']")