Sum of List Elements

Calculate the sum of all elements in a list of numbers.

BeginnerTopic: List Programs
Back

Python Sum of List Elements Program

This program helps you to learn the fundamental structure and syntax of Python programming.

Try This Code
# Program to find sum of list elements

numbers = list(map(float, input("Enter numbers separated by space: ").split()))

print("Sum of elements:", sum(numbers))
Output
Enter numbers separated by space: 1 2 3 4
Sum of elements: 10.0

Understanding Sum of List Elements

We read space-separated numbers, convert them to float, and use the built-in sum() to add them.

Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.

Table of Contents