How do I split strings within nested lists in Python?
问题 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