convert a string to list in python code example
Example 1: string list into list pandas
import ast
ini_list = "[1, 2, 3, 4, 5]"
res = ast.literal_eval(ini_list)
print ("final list", res)
print (type(res))
Example 2: convert string to list python
word = 'abc'
L = list(word)
L
word = 'a,b,c'
L = word.split(',')
L
Example 3: python convert string to list
fruit = 'apple oranges banans'
newlist = fruit.split()
print(newlist)
Example 4: python string to tuple
l = list('abcd')
l = map(None, 'abcd')
l = [i for i in 'abcd']
import re
l = re.findall('.', 'abcd')
print(l)
Example 5: convert string to list python
word = "Hey Hello world"
print(list(word))