Suppose i have the following for loop
L=[]
for e in C:
t=0
for r in D:
if r[0]==e:
t=t+r[2]
L.append((e,t))
To give some more information e is a list, r is a tuple of size 3. I also want each element of L to contain a tuple.
How do i write the following in a list comprehension? I'm unsure as there are variable assignments in the for loop. I'd really appreciate any help! Thanks!!