Suppose I am having a list of lists (containing tokens of sentences).
For example:
new_list = ['hello', 'folks', 'i', 'am', 'a', 'good', 'boy', '.'], ['python', 'is', 'a', 'language', '.']]
I want to merge them back into a single list?
How to achieve this? Any shortcut for this?
Output:
['hello folks i am a good boy.', 'python is a language'.]
What I have tried is as follows:
1) new_list_1 = (''.join(str(new_list)))
2) from itertools import chain
new_list_1 = list(chain(*new_list))
At present I am getting the output (in terms of merged tokens only) as:
new_list_1 = ['hello', 'folks', 'i', 'am', 'a', 'good', 'boy', '.' 'python', 'is', 'a', 'language', '.']