0

I was looking at the answer at following link https://stackoverflow.com/a/638069 but couldn't understand how does it perform

sum(i for i, j in list_of_pairs)

I think it will only sum up the first value of the tuples in the

list_of_pairs
HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Kapil
  • 103
  • 1
  • 5
  • 1
    Note that the question is titled "How do I sum the first value in each tuple". So your analysis is likely correct. – Silvio Mayolo Jun 24 '19 at 23:55
  • Read about generator expressions and play around with the line to understand it. E. g. you can replace the "sum" by "list" to see which items are generated. – Michael Butscher Jun 25 '19 at 00:09

1 Answers1

0

Yes, it only sums the first value of the tuples in the list.

Lee Garcon
  • 182
  • 10