Adding elements of a list containing relativedelta objects

  list, python, python-3.x, relativedelta

I have a list myList that contains relativedelta objects. I want to add all of these relativedeltas objects.
I tried:

sum(myList)

but it gives TypeError.

TypeError: unsupported operand type(s) for +: 'int' and 'relativedelta'

Even though relativedelta objects can be added with + Opeartor

Source: Python Questions

LEAVE A COMMENT