In this article, we will learn to find the sum of the elements in a List using the python program.
We find the sum of the elements in the list using 3 methods:
- Using loop
- Using Recursion
- Using sum() function
Using iteration of the list, we add the elements one by one in a variable and lastly print the sum of the elements.
Using recursion we find the sum of the elements of the list. Ada last elements and update the size value to -1 and add one by one.
Using sum() function
The sum() function is used to find the sum of all elements.