Answers for "how to turn a list into a list of stings"

4

python string list to list

>>> import ast
>>> x = '[ "A","B","C" , " D"]'
>>> x = ast.literal_eval(x)
>>> x
['A', 'B', 'C', ' D']
>>> x = [n.strip() for n in x]
>>> x
['A', 'B', 'C', 'D']
Posted by: Guest on May-06-2021
0

string list to list

import ast

l1 = ['aa','bb','cc']
s = str(l1)
ast.literal_eval(s)
>>> ['aa','bb','cc']
Posted by: Guest on January-11-2022

Code answers related to "how to turn a list into a list of stings"

Python Answers by Framework

Browse Popular Code Answers by Language