Dec-12-2017, 07:22 PM
import collections Person = collections.namedtuple('Person', ['Name', 'Age', 'Height', 'Weight']) person1 = Person(Name='Bob', Age=55, Height=165, Weight=70) person2 = Person(Name='Doe', Age=45, Height=185, Weight=90) person3 = Person(Name='John', Age=50, Height=175, Weight=85) people = [person1, person2, person3]I have a list of namedtuple with people and their names, ages, heights and weights.
I want to know how to sum the people's total ages.
For my above example, the total ages = 55 + 45 + 50 = 150
Thanks,