Open In App

Python | Addition of tuples

Last Updated : 05 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In Python, tuples are immutable sequences used to store multiple items. Adding tuples refers to concatenating two or more tuples to form a new one.

Since tuples cannot be modified, original tuples remain unchanged and the result is a new tuple containing all the elements in order.

Example:

Python
t1 = (1, 2)
t2 = (3, 4)
T = t1 + t2
print(T) 

Output
(1, 2, 3, 4)

Let's explore some methods to perform addition on tuple.

Using Numpy

When adding tuples converting them to NumPy arrays allows fast and efficient computation using add() function.

Python
import numpy as np
t1 = (10, 4, 5)
t2 = (2, 5, 18)
res = tuple(np.add(np.array(t1), np.array(t2)).tolist())
print(res)

Output
(12, 9, 23)

Explanation: add() performs element-wise addition of two tuples, then converts the result to a tuple using tolist() to remove NumPy types.

Using map()+ zip() + sum()

zip() function pairs elements by position, sum() adds each pair and map() applies sum() to all pairs for element-wise tuple addition.

Python
t1 = (10, 4, 5)
t2 = (2, 5, 18)
res = tuple(map(sum, zip(t1, t2)))
print(res)

Output
(12, 9, 23)

Explanation:

  • zip(t1, t2) pairs elements by position: (10, 2), (4, 5), (5, 18).
  • sum adds each pair: 12, 9, 23.
  • map() applies sum to each pair and tuple() converts the result into a tuple.

Using map() + lambda

map() with lambda allows element-wise addition of tuples by applying addition function to each pair of elements.

Python
t1 = (10, 4, 5)
t2 = (2, 5, 18)
res = tuple(map(lambda x, y: x + y, t1, t2))
print(res)

Output
(12, 9, 23)

Explanation:

  • map() applies lambda function to each pair of elements: 10+2, 4+5, 5+18.
  • lambda function adds each pair: 12, 9, 23.

Using list comprehension

List comprehension adds two tuples by summing their elements at each index and converting the result into a new tuple.

Python
t1 = (10, 4, 5)
t2 = (2, 5, 18)
res = tuple(t1[i] + t2[i] for i in range(len(t1)))
print(res)

Output
(12, 9, 23)

Explanation:

  • range(len(t1)) generates indices 0, 1 and 2 to loop through tuple elements.
  • t1[i] + t2[i] adds elements at the same index from both tuples: 10+2, 4+5, and 5+18.

Using for loop

A loop can add two tuples by iterating through their elements, summing them one by one, storing the results in a list and finally converting that list to a tuple.

Python
t1 = (10, 4, 5)
t2 = (2, 5, 18)
res = []
for i in range(len(t1)):
    res.append(t1[i] + t2[i])

res = tuple(res)
print(res)

Output
(12, 9, 23)

Explanation:

  • range(len(t1)) generates indices 0, 1, and 2 to loop through the tuples.
  • t1[i] + t2[i] adds elements at the same index from both tuples and appends the result to the list res.
  • tuple(res) converts the list into a tuple.

Related Articles:


Practice Tags :

Similar Reads