Does anyone know how it's possible to add up the values in a list?

Recommended Answers

Use the sum function.

Jump to Post

All 5 Replies

Use the sum function.

sum

So it would be like:
list.sum()

$ pydoc sum
Help on built-in function sum in module __builtin__:

sum(...)
    sum(sequence[, start]) -> value

    Returns the sum of a sequence of numbers (NOT strings) plus the value
    of parameter 'start' (which defaults to 0).  When the sequence is
    empty, returns start.
(END)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.