I know how to split a list of strings into a nested list using those strings, but I'm not specifically sure how I would go about splitting those strings now into multiple strings.
For example:
def inputSplit(file_name):
with open(file_name) as f:
content = f.read().splitlines()
i = 0
contentLists = [content[i:i+1] for i in range(0, len(content), 1)]
Would give me something like:
[['these are some words'], ['these are some more words'], ['these are even more words'], ['these are the last words']]
I'm not sure how to use the string split to make my output look like this:
[['these', 'are', 'some', 'words'], ['these', 'are', 'some', 'more', 'words'], ['these', 'are', 'even', 'more', 'words'], ['these', 'are', 'the', 'last', 'words']]
Is there a way I can go about this?
content = f.readlines()would be simpler and more efficient. There is an even simpler and more efficient solution, though (see my answer, for instance).