#提高Python列表数据处理的速度

问题遇到的现象和发生背景

用for循环遍历列表 如何让满足条件的数据拿出后在列表中删除,下一次寻找时的次数变少

问题相关代码,请勿粘贴截图

b=[]
for temp in a:
for ele in dataele:
if temp==ele[0]:
#save the node number in this element
point1 = ele[1]
for nh in datanode:
if nh[0] == point1:
b.append(nh[3])
continue
# if nh == datanode[-1] and nh[0]!=point1:
# print(point1)
continue

运行结果及报错内容

多重循环速度太慢

我想要达到的结果

想提高运行速度

continue毫无意义,改成break
如果你需要去list里筛选数据,你一开始定义成dict不就好了,复杂度O(1)