Create a List of Tuples with Numbers and Their Cubes Python (original) (raw)

Last Updated : 25 Oct, 2025

Given a list of numbers, the task is to create a list of tuples where each tuple contains a number and its cube. **For example:

**Input: [1, 2, 3]
**Output: [(1, 1), (2, 8), (3, 27)]

Let’s explore different methods to achieve this efficiently in Python.

Using List Comprehension

This method uses list comprehension to generate the tuples directly while iterating over the list.

Python `

a = [1, 2, 3, 4, 5] res = [(n, n**3) for n in a] print(res)

`

Output

[(1, 1), (2, 8), (3, 27), (4, 64), (5, 125)]

**Explanation:

Using map() with lambda

map() function applies a transformation function to each element of an iterable. It can be used with a lambda function to create the desired list of tuples.

Python `

a = [1, 2, 3, 4, 5] res = list(map(lambda n: (n, n**3), a)) print(res)

`

Output

[(1, 1), (2, 8), (3, 27), (4, 64), (5, 125)]

**Explanation:

Using zip()

This method separates numbers and their cubes into two lists and then combines them with zip().

Python `

a = [1, 2, 3, 4, 5] res = list(zip(a, [n**3 for n in a])) print(res)

`

Output

[(1, 1), (2, 8), (3, 27), (4, 64), (5, 125)]

**Explanation:

Using for Loop with append()

This method uses a standard loop to build the list incrementally.

Python `

a = [1, 2, 3, 4, 5] res = [] for n in a: res.append((n, n**3)) print(res)

`

Output

[(1, 1), (2, 8), (3, 27), (4, 64), (5, 125)]

**Explanation: