I'm trying to cut a list by specific items in it, for example, I have a list like this:
down = ["a", "b", "c", "d", "b", "e", "r"]
Run Code Online (Sandbox Code Playgroud)
What I want is:
[["a", "b"]["c", "d", "b"] ["e", "r"]]
Run Code Online (Sandbox Code Playgroud)
which is cut after every occurrence of "b".
I wrote something like this:
down = ["a", "b", "c", "d", "b", "e", "r"]
up = []
while down is not []:
up, down = up.append(down[:(down.index("b") + 1)]), down[(down.index("b") + 1):]
Run Code Online (Sandbox Code Playgroud)
It throws …