I am having a hard time merging the elements within the Python list according to a given number.
I already found the solution to work on with a certain number. But I want to work with a variety of given number(N).
i.e. When I have a list
['There', 'was', 'a', 'farmer', 'who', 'had', 'a', 'dog', 'and', 'cat', '.']
Result,
When N = 2
['There was', 'a farmer', 'who had', 'a dog', 'and cat', '.']
or N = 3
['There was a', 'farmer who had', 'a dog and', 'cat .']
I would much prefer that it modified the existing list directly, not used any module or library.
Any help is greatly appreciated!!