>>> phonelist = [[12,14,16,17,18],[16,23,54,64,32]]
>>> [sum(li) for li in phonelist]
[77, 189]
>>> sum([sum(li) for li in phonelist])
266

or:

>>> sum(sum(li) for li in phonelist)    # generator expression...
266

If you are trying to create individual categories, you can use a dict:

data={'Bar {}'.format(i):sum(li) for i, li in enumerate(phonelist, 1)}
data['Total']=sum(data.values())

print data
{'Bar 2': 189, 'Bar 1': 77, 'Total': 266}

Then if you want to produce a simple bar graph:

for bar in sorted(data.keys()):
    print '{}: {}'.format(bar, int(round(25.0*data[bar]/data['Total']))*'*')

Prints:

Bar 1: *******
Bar 2: ******************
Total: *************************
Answer from dawg on Stack Overflow
๐ŸŒ
University of Vermont
uvm.edu โ€บ ~cbcafier โ€บ cs1210 โ€บ book โ€บ 11_loops โ€บ loops_and_summation.html
Math and Python: loops and summation โ€“ Clayton Cafiero
We begin with a tuple of numeric values, t. Since the elements of t are all numeric, we can calculate their sum. First, we create a variable to hold the result of the sum. We call this, sum_.1 Then, we iterate over all the elements in t, and at each iteration of the loop, we add the value of ...
Discussions

How can I find the sum of the numbers in a list for a 'for' loop?
You print on every loop, but you only want to print when the loop has finished More on reddit.com
๐ŸŒ r/learnpython
20
1
June 1, 2024
Given a list of numbers, calculate their sum using a for loop. Output the sum after the loop
x = [42, 8, 7, 1, 0, 124, 8897, 555, 3, 67, 99] sum = 0 for n in x: sum+=n print(sum) More on sololearn.com
๐ŸŒ sololearn.com
13
4
How can i sum the value in list with for loop in python? - Stack Overflow
Or you could build up the sum e.g. by doing: total = 0 for i in ds: total += i * i print(total) ... Sign up to request clarification or add additional context in comments. ... @uud I put the print statement outside the loop, that's why you only see 55. More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to calculate min/max values in a list without using the min()/max() functions?
You have the right idea. You don't need to make a new loop, though. Just keep track of the maximum score while the data is being entered. More on reddit.com
๐ŸŒ r/learnpython
8
2
February 25, 2015
๐ŸŒ
Python Guides
pythonguides.com โ€บ sum-elements-in-list-in-python-using-for-loop
How to Sum Elements in a List in Python
November 10, 2025 - The most obvious way to add numbers stored in a list is to use a for-loop. The following code fragment visits each list element in order and totals the sum of its elements.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how can i find the sum of the numbers in a list for a 'for' loop?
r/learnpython on Reddit: How can I find the sum of the numbers in a list for a 'for' loop?
June 1, 2024 -

I'm a complete beginner. I've been following a course through Solo Learn, and it's been okay, but the latest lesson was really poorly explained. (It wasn't explained at all. I had to rely on comments in the lesson to actually learn things. Really rough.)

The lesson is ending in a practice exercise with the following directions:

Given a list of numbers, calculate their sum using a for loop.

There's just one problem! They haven't taught us how to add anything in a for loop. After some digging on Google and Stack Overflow, I learned a few things, but I still haven't gotten the correct answer. I keep just getting wrong answers.

This is what my current code looks like. I'm at a loss and don't know what to do at this point. The list is provided by the course and I can't change it. Other than the first line, I wrote everything else.

The expected outcome is: 9803

list = [42, 8, 7, 1, 0, 124, 8897, 555, 3, 67, 99]
sum = 0

for x in list:
    sum = sum + x
    print(sum)

The outcome to this problem with my current code is: 42 50 57 58 58 182 9079 9634 9637 9704 9803

I have no idea why this happens. I just need that bottom number, but I don't know how to get it.

I originally tried doing something like

for x in list:
    sum += x
    print(sum)

But that didn't work either.

Any guidance would be really appreciated. I'm sorry if this is a simple solution, but they didn't teach us how to do this at all. Instead, they focused on modulus operations (%) for the lesson. That was really poorly explained too.

I found a similar question on Stack Overflow here. But it wasn't very helpful, and the answers use things that I haven't learned yet.

I don't know. Maybe I'm not smart. I'm not sure what to do now.

Any help is appreciated, thank you.

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ sum-function-python
sum() function in Python - GeeksforGeeks
November 27, 2025 - A for loop can be used to add elements of a list one by one. This method shows how summation works step-by-step and is useful when you need full control over how each value is processed during the calculation.
๐ŸŒ
PyTutorial
pytutorial.com โ€บ python-list-summation-methods-examples
PyTutorial | Python List Summation: Methods & Examples
January 26, 2026 - # Example 3: Summation with a for loop values = [1, 2, 3, 4, 5] running_total = 0 for num in values: running_total += num # Add the current number to the total print("The sum is:", running_total) ...
Find elsewhere
๐ŸŒ
Python Mania
pythonmania.org โ€บ home โ€บ blog โ€บ how to sum a list in python using for loop
How To Sum A List In Python Using For Loop - Python Mania
May 19, 2023 - Inside the loop, we add the current element num to the total variable using the += operator. This updates the sum with each iteration.
๐ŸŒ
Altcademy
altcademy.com โ€บ blog โ€บ how-to-sum-a-list-in-python
How to sum a list in Python - Altcademy.com
September 10, 2023 - For each iteration, we add the current number to the total. The += operator is a shorthand for total = total + number. Python also provides a more concise way to sum a list using a technique called list comprehension.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-program-to-find-sum-of-elements-in-list
Find sum of elements in List - Python - GeeksforGeeks
Explanation: For loop iterates through each element in the list, adding it to res in each step until all elements are summed. List comprehension allows you to create a new list based on an existing one and then use sum() to calculate the total.
Published: August 13, 2026
๐ŸŒ
STechies
stechies.com โ€บ find-sum-elements-list-python
How to Find the Sum of Elements in a List in Python
# Python code to calculate sum of integer list # Using for loop # Declare list of numbers numlist = [2,4,2,5,7,9,23,4,5] # Calculate sum of list numsum=0 for i in numlist: numsum+=i print('Sum of List: ',numsum)
๐ŸŒ
PythonForBeginners.com
pythonforbeginners.com โ€บ home โ€บ sum of elements in a list in python
Sum Of Elements In A List In Python - PythonForBeginners.com
January 27, 2022 - We often need to perform different operations on lists. In this article, we will discuss different ways to find the sum of elements in a list in python. The first way to find the sum of elements in a list is to iterate through the list and add each element using a for loop.
๐ŸŒ
codippa
codippa.com โ€บ home โ€บ how to find sum of elements of list in python
How to find sum of elements of list in python - codippa
March 1, 2024 - This article shall detail out different ways in which this can be done. This method is based on the below algorithm. 1. Initialize a variable to hold the sum of element. 2. Iterate over the list using a for loop and retrieve each element of the list.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-compute-the-sum-of-a-list-in-python
How to compute the sum of a list in python
Python provides various ways to compute the sum of a list, including simple loops, recursion, and the built-in sum() function.
๐ŸŒ
Real Python
realpython.com โ€บ python-sum-function
Python's sum(): The Pythonic Way to Sum Values โ€“ Real Python
March 18, 2026 - Visualize what you are asking a loop to do when summing a list of values. You want it to loop over some numbers, accumulate them in an intermediate variable, and return the final sum.
๐ŸŒ
Quora
quora.com โ€บ How-do-you-sum-up-all-items-in-a-list-in-Python
How to sum up all items in a list in Python - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ python-program-to-find-sum-of-elements-in-a-list
Python Program to find Sum of Elements in a List
September 4, 2018 - This program allows users to enter the length of a List. Next, we used For Loop to add numbers to the list. The sum function returns the sum of all the elements in a List. Refer to the Python List article and the built-in Python fsum function.