Tomm
0
Q:

convert string to list python

fruit = 'apple oranges banans'
newlist = fruit.split()
print(newlist)
2
# To split the string at every character use the list() function
word = 'abc'
L = list(word)
L
# Output:
# ['a', 'b', 'c']

# To split the string at a specific character use the split() function
word = 'a,b,c'
L = word.split(',')
L
# Output:
# ['a', 'b', 'c']
12
word = "Hey Hello world"
print(list(word))
# output
# ["Hey", "Hello", "world"]
1
s = 'hello'
l = list(s)
print(l) # prints ['h', 'e', 'l', 'l', 'o']
5
# Python code to convert string to list 
  
def Convert(string): 
    li = list(string.split(" ")) 
    return li 
  
# Driver code     
str1 = "Geeks for Geeks"
print(Convert(str1)) 
0

New to Communities?

Join the community