# Python program to calculate the sum of elements in a list

Hello everyone, am back to discuss a new python program. Here we learn how to sum all the elements in a list quite easily. We use a predefined function called `sum()` and apply it to the list, the functions returns the sum of all the elements in a list.

Pro Programming Tip: Migrate your software development/testing environment into the hassle-free cloud with high-performance Citrix XenDesktop at an affordable XenDesktop pricing from CloudDesktopOnline and remotely access your preferred programming tools such as emulators and IDE`s on your preferred device(PC/Mac/Linux/Android/iOS). Learn more about MS Azure and managed Azure services by visiting Apps4Rent.

#### Video :

You can also watch the video on YouTube here

To find the sum of all the elements in a list.

#### Approach :

• Read input number asking for the length of the list using `input()` or `raw_input()`.
• Initialize an empty list `lst = []`.
• Read each number using a `for loop`.
• In the for loop append each number to the list.
• Now we use a predefined function `sum()` to find the sum of all the elements in a list.
• Print the result.

#### Output :

##### Course Suggestion

Want to learn python with strong fundamentals? If yes, I strongly suggest you to take the course below.
Course: Fundamentals of Programming in Python

1. Ashutosh Singh

it gives an type error : int object is not callable

2. Don

How do you write this code in a way to identify each number as follows:
Enter number 1:
Enter number 2:
Enter number:3
And so forth
And calculate: the sum.for that list?

Thank you

3. I’m trying to create a program to figure all the ways you can sum to a number with digits (i.e. 1 – 9) using each digit only once. So far I have a series of for loops, but it’s really slow. Is there a better / more efficient way?

4. anonymous

what if the numbers in array has decimals

This site uses Akismet to reduce spam. Learn how your comment data is processed.