I need some help converting the following nested for loop into a list comprehension.
adj_edges = []
for a in edges:
adj = []
for b in edges:
if b[0] < a[0] and b[1] >= a[0] and b[1] <= a[1]:
adj.append(b)
adj_edges.append((a[0], adj))
where edges is a list of lists like this [[0, 200], [200, 400]]
I’ve used list comprehensions before but i don’t know why im having trouble with this one.
here it is:
this is an interactive session showing the two alternative approaches: