Advertisement
here2share

# ij_nest2split.py

Dec 31st, 2024
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. # ij_nest2split.py
  2.  
  3. import itertools
  4.  
  5. sentence = "this is just a test"
  6. words = sentence.split()
  7.  
  8. splits = []
  9. for i in range(0, len(words)):
  10.     for j in range(i + 1, len(words) + 1):
  11.         split = words[i:j]
  12.         splits.append(split)
  13.        
  14. for split in splits:
  15.     print(split)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement