Python string list to list code example
Example 1: list to string python
list1 = ['1', '2', '3']
str1 = ''.join(list1)
Example 2: python convert list to list of strings
lsit_of_strings = [str(i) for i in your_list]
your_list = ['strings', 'and', 'numbers', 11, 23, 42]
lsit_of_strings = [str(i) for i in your_list]
print(lsit_of_strings)
--> ['strings', 'and', 'numbers', '11', '23', '42']
Example 3: string to list python
s = 'hello'
l = list(s)
print(l)
Example 4: how to convert a string to a list python
string.split("separator")
Example 5: python list of list to list of string
list_of_string = [''.join(element) for element in list_of_list]
Example 6: 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']