i have a scenario like this one:
mainList = [[9,5],[17,3],[23,1],[9,2]]
secondaryList = [9,12,28,23,1,6,95]
myNewList = []
myNewList.append([[a,b] for a,b in mainList if a in secondaryList])
this, return me to me:
myNewList = [[9,5],[23,1],[9,2]]
但我只需要第一个出现的“a”。换句话说,我需要获得:
myNewList = [[9,5],[23,1]]
如何实现这个目标?