---
title: "sum"
space: "Student Handbook"
url: "https://portal.cs17.org/student-handbook/python-manual/built-in-functions/sum"
updated: "2026-10-05"
---

Adds up all the numbers in a list.

## Synopsis

```python
sum(list)
```

## Description

`sum` adds every item, starting from 0. For an empty list it returns `0`.

## Parameters

| Name | Meaning |
| --- | --- |
| `list` | A list (or range) of numbers. |

## Return value

The total, an `int` or a `float`.

## Example

```python
print(sum([1, 2, 3]))
print(sum(range(1, 101)))
print(sum([]))
```

It prints:

```text
6
5050
0
```

## Common mistake

```python
print(sum(["a", "b", "c"]))
```

Python stops with:

```text
TypeError: unsupported operand type(s) for +: 'int' and 'str'
```

`sum` adds numbers only. To join strings, use `"".join(...)`.

## See also

[len](/student-handbook/python-manual/built-in-functions/len), [min](/student-handbook/python-manual/built-in-functions/min), [max](/student-handbook/python-manual/built-in-functions/max), [str.join](/student-handbook/python-manual/strings/join)

[sum in the Python documentation](https://docs.python.org/3/library/functions.html#sum)
