0

I have i and need o.

i = ["file1", "file2", "join", "file3", "file4", "join", "file5", "file6"]


o = [["file1", "file2", "join"], ["file3", "file4", "join"], "file5", "file6"]

I tried so many hours and attempts that I can't reasonably show what I tried so far. while, pop, index etc come to my mind. Please bear with me, if I now only put these plain lines in order to ask for your precious help.

mozway
  • 194,879
  • 13
  • 39
  • 75
jjk
  • 592
  • 1
  • 6
  • 23
  • 1
    Is the condition to group consecutive items together until the last character of a string is not numerical? Or is it until you find the word "join"? Or a 4-character string? Or a word that doesn't start with "file"? Or something else? And are "file5" and "file6" just appended to the output because you didn't hit upon the condition to group them together into a sublist? – Reti43 Sep 27 '21 at 21:19
  • 1
    What did you try *so many hours* ? What do you need to do? Share the expected output? – balderman Sep 27 '21 at 21:21
  • Share the attempt you were convinced would work the most, explain what you expected and what happened instead and people will be able to explain why it didn't work and how to improve on it. Surely one of the ideas you had in many hours will have felt close? – Grismar Sep 27 '21 at 21:24
  • 1
    actually `split_after` is **not** giving the expected output – mozway Sep 27 '21 at 21:44
  • @mozway Indeed. The ungrouped items (file5 and file6) should **not** be in a list. However I can easily post another question based on your suggestion. – jjk Sep 28 '21 at 17:22
  • @jjk up to you, depends if you need it ;) this would be a variation on `split_after` – mozway Sep 28 '21 at 17:26

0 Answers0