Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # split_combos.py
- import itertools
- sentence = "this is just a test"
- words = sentence.split()
- splits = []
- for i in range(1, len(words)):
- for indices in itertools.combinations(range(1, len(words)), i):
- split = [words[i:j] for i, j in zip((0, *indices), (*indices, len(words)))]
- splits.append(split)
- for split in splits:
- print(split)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement