我正在尝试按其中的特定项目剪切列表,例如,我有一个这样的列表:
down = ["a", "b", "c", "d", "b", "e", "r"]
我想要的是:
[["a", "b"]["c", "d", "b"] ["e", "r"]]
在每次出现"b".
我写了这样的东西:
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):]
它抛出一个错误:
AttributeError: 'NoneType' object has no attribute 'append'
我无法弄清楚出了什么问题。
慕斯709654
一只名叫tom的猫
精慕HU
相关分类