2013-02-20 180 views

回答

0

使用enumerate

new_lista = [j for i, j in enumerate(lista) if i not in listb] 
+0

非常感谢! – Alwina 2013-02-20 11:59:58

1

您可以尝试以下。

for x in sorted(listb,reverse=True): lista.pop(x) 

此外,您可能需要确保listb不包含重复索引,并且所有索引号都是有效索引。

for x in sorted(set([y for y in listb if -1 < y < len(lista)]),reverse=True): lista.pop(x)