a = ['12','45','23','78','14']
b = [['17', 'aa'], ['14', 'bb'], ['24', 'cc'], ['01', 'dd'], ['45', 'ee'], ['']]
如何从列表b中获取列表中的数字列表a(['14', 'bb']
和['45', 'ee']
)并加入此列表:
['14 bb'], ['45 ee']
我无法使用for循环并加入...
答案 0 :(得分:0)
a = ['12','45','23','78','14']
b = [['17', 'aa'], ['14', 'bb'], ['24', 'cc'], ['01', 'dd'], ['45', 'ee'], ['']]
ans=[]
for items in b:
if items[0] in a:
ans.append(items)
print(ans)