I have structure like this:
structure = [('a', 1), ('b', 3), ('c', 2)] I would like to sum the integers (1+3+2) using sum() builtin method (in one line).
Any ideas?
sum(n for _, n in structure) would work.
sum(x[1] for x in structure) should work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With