Home » Find Sum of Tuple Items using Python

Find Sum of Tuple Items using Python

by maxguy71

In this example we use the sum function to return the sum of all tuple items.

Example

# Sum of All Items

number_tuple = (10, 20, 30, 40, 50, 60, 70, 80, 90)
print("Tuple Items = ", number_tuple)

tuple_sum = sum(number_tuple)
print("\nThe Sum of Tuple Items = ", tuple_sum)

When you run this you will see something like this

>>> %Run sumtuple.py
Tuple Items =  (10, 20, 30, 40, 50, 60, 70, 80, 90)

The Sum of Tuple Items =  450

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More