Calculations between the object properties that belongs to same class in Python

class Person():

     def __init__(self,name,age,salary):
        self.age =age
        self.name=name
        self.salary=salary

mike = Person('mike',20,2000)
john = Person('john',25,2500)

totalSalary=mike.salary + john.salary
print(totalSalary)

I would like find total salary that a firm pays to all employees, but this solution does not look a good way as maybe 5000 employees could be working for the company. So what would be the best way to cope with it?

Answer

Using sum

totalSalary = sum(person.salary for person in [mike, john])

Output

4500