I have a list of lists of tuples:
oldList = [[(1,None),(2,45),(3,67)],[(1,None), (2,None), (3,None),(4,56),(5,78)],[(1, None),(2, 98)]]
I would like to filter any instance of "None":
newList = [[(2,45),(3,67)], [(4,56),(5,78)], [(2, 98)]]
The closest I've come is with this loop, but it does not drop the entire tuple (only the 'None') and it also destroys the list of lists of tuples structure:
newList = []
for data in oldList:
for point in data:
newList.append(filter(None,point))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…