Q:

convert string into list

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
# 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