(Jan-05-2023, 06:03 PM)kinimod Wrote: Although what I'm looking for is to use the reduce function to add up all the numbers.
Alternative to bowlofred solution is to stream only age and use lambda to add up:
from functools import reduce data = [("Rachel",19), ("Monica",18), ("Phoebe",17), ("Joey",16), ("Ross",20), ("Chandler",21)] total = reduce(lambda x, y: x+y, (age for _, age in data)) # total -> 111Of course, for adding there is built-in function sum:
sum(age for _, age in data)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.