Here, 'list' is my list of strings, i want to split 'a b' into 'a','b' and merge it back into the list with other strings
list = ['abc','a b', 'a b c','1234']
Expected Output after splitting = ['abc','a','b','a','b','c','1234']
Here, 'list' is my list of strings, i want to split 'a b' into 'a','b' and merge it back into the list with other strings
list = ['abc','a b', 'a b c','1234']
Expected Output after splitting = ['abc','a','b','a','b','c','1234']
Try this code
lis = ['abc', 'a b', 'a b c', '1234']
lis1 = []
for i in lis:
b = i.split()
lis1.extend(b)
print lis1
Output:-
['abc', 'a', 'b', 'a', 'b', 'c', '1234']
try this code
' '.join(list).split(' ')
output
['abc', 'a', 'b', 'a', 'b', 'c', '1234']