基本上,我需要一种方法将控制权返回到 for 循环的开头,并在满足特定条件后采取行动后实际重新启动整个迭代过程。
我想要做的是:
for index, item in enumerate(list2):
if item == '||' and list2[index-1] == '||':
del list2[index]
*<some action that resarts the whole process>*
这样,如果 ['berry','||','||','||','pancake] 在列表中,我将得到:
['berry','||','pancake'] 代替。
谢谢!