You probably know a sort-of universal way of finding the sum of elements in a list is pretty much all programming languages out there:
Iterate through a list of elements and then keep on adding the value of that element to a variable in which you have initialized before the start of the iteration.
In other words, it is just a general algorithm that resembles the way you would find the sum on a piece of paper:
However, there is also a quick way that you can find this sum in Python which is not present in every programming language out there.
You can find it by simply calling sum():
Yes, it’s that simple and you may have already seen it somewhere else already, but I wanted to also inform others who may have not had the chance to see it before.
I hope you find it useful.