Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to join lists by condition?
Hello! I can't find a nice way to join 2 lists.
There are 2 lists (lists have 15000+ sublists):
a = [[1, 100], [2, 200], [3,300], ...]
b = [[1, 110], [3,330], ...]
с = [[1, 100, 110], [2, 200], [3, 300, 310], ...]
Answer the question
In order to leave comments, you need to log in
a = [[i, i*100] for i in range(15000)]
b = [[i, i*110] for i in range(15000)]
c = {}
for i in a+b:
c.setdefault(i[0], []).append(i[1:])
for i in a+b
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question