Python tuple() Function: Syntax and 6 Examples

If you want to turn a list or any iterable into a tuple in Python, the Python tuple function does exactly that. It takes the iterable and gives you back a new tuple with the same items in the same order.

print(tuple([3, 1, 2]))
# (3, 1, 2)

In this tutorial, I’ll show you tuple() in six examples: empty tuples, freezing a list, converting dicts and ranges, dictionary keys, generators and zip(). You’ll see real output from Python 3.12.5 in Command Prompt.

Python tuple() Syntax

tuple(iterable=(), /)
ParameterRequiredDefaultDescription
iterableNo()A sequence, container or iterator (positional only)

Return value: a new tuple. If you pass a tuple, Python hands back the same object.

Note: tuples can’t change after creation. For the full picture, see mutable vs immutable in Python.

When to Use tuple() in Python

  • Freezing a list
  • Using a list of values as a dictionary key
  • Collecting generator results
  • Returning several values from a function

For the basics of the type itself, read how to declare and use tuples in Python.

Example 1: Create an Empty Tuple with tuple()

Let me start with no argument, a string and an existing tuple:

empty = tuple()
print(empty, type(empty))
print(tuple("USD"))

codes = ("TX", "CA")
print(tuple(codes) is codes)

Output:

() <class 'tuple'>
('U', 'S', 'D')
True
Python tuple function creating an empty tuple and splitting a string into characters
An empty tuple, three letters and True.

How does this work? tuple() returned (), and “USD” split into three letters. The is check printed True, so no copy was made.

Example 2: How Do I Convert a List to a Tuple in Python?

Say you pulled cart prices from an Excel sheet and want a snapshot you can’t edit by accident:

prices = [19.99, 4.50, 12.75]
frozen = tuple(prices)

print(frozen)
prices.append(8.25)
print(prices)
print(frozen)

Output:

(19.99, 4.5, 12.75)
[19.99, 4.5, 12.75, 8.25]
(19.99, 4.5, 12.75)
Python tuple function converting a list of prices into a tuple snapshot
The list grew; the tuple didn’t.

How does this work? The tuple copied the three prices. Appending 8.25 changed only the list.

More conversion options: creating a tuple from a list in Python.

Example 3: Convert a Dictionary or range to a Tuple

Python’s tuple() accepts any iterable:

stock = {"SKU-101": 12, "SKU-205": 0}

print(tuple(stock))
print(tuple(stock.items()))
print(tuple(range(2024, 2027)))

Output:

('SKU-101', 'SKU-205')
(('SKU-101', 12), ('SKU-205', 0))
(2024, 2025, 2026)

How does this work? A dict gives its keys, .items() gives pairs, and the range gave three years. A pandas row or NumPy array converts the same way.

Example 4: Use tuple() to Make a Dictionary Key

Lists can’t be dictionary keys, but tuples can. Here I count visits to two Texas stops:

stops = [[32.78, -96.80], [29.76, -95.37]]
visits = {}

for stop in stops:
    visits[tuple(stop)] = visits.get(tuple(stop), 0) + 1

print(visits)
print(visits[(29.76, -95.37)])

Output:

{(32.78, -96.8): 1, (29.76, -95.37): 1}
1
Python tuple function turning list coordinates into dictionary keys
Coordinates became tuple keys.

How does this work? Each inner list became a hashable tuple, so Dallas and Houston got one count each.

Example 5: Convert a Generator Expression to a Tuple

Python has no tuple comprehension, so wrap a generator in tuple(). Here I add 8.25% sales tax:

subtotals = [25.00, 40.00, 15.50]
taxed = tuple(round(s * 1.0825, 2) for s in subtotals)

print(taxed)
print(f"Total: ${sum(taxed):.2f}")

Output:

(27.06, 43.3, 16.78)
Total: $87.14
Python tuple function collecting taxed order subtotals from a generator
Three taxed amounts and their total.

How does this work? The generator produced each taxed amount, and tuple() stored them. The total came to $87.14.

Functions often hand results back like this: returning a tuple in Python.

Example 6: Combine tuple() with zip() and sorted()

You’ll often use tuple() with zip() and sorted():

cities = ["Denver", "Austin", "Boston"]
highs = [41, 68, 37]

pairs = tuple(zip(cities, highs))
print(pairs)
print(tuple(sorted(highs, reverse=True)))

Output:

(('Denver', 41), ('Austin', 68), ('Boston', 37))
(68, 41, 37)

How does this work? zip() paired each city with its high, and tuple() made it fixed. sorted() returns a list, so tuple() converted it back.

Sorting tuples in place? See how to sort a tuple in Python.

Common Mistakes with Python tuple()

These are the Python tuple() errors I see most:

def m1(): return tuple(2026)
def m2(): return tuple(1, 2)
def m3():
    t = tuple([10, 20])
    t[0] = 99
def m4(): tuple(["a"]).append("b")

for n, test in enumerate([m1, m2, m3, m4], 1):
    try:
        test()
    except (TypeError, AttributeError) as err:
        print(f"{n}. {type(err).__name__}: {err}")

print("5.", tuple("Dallas"), "vs", ("Dallas",))

Output:

1. TypeError: 'int' object is not iterable
2. TypeError: tuple expected at most 1 argument, got 2
3. TypeError: 'tuple' object does not support item assignment
4. AttributeError: 'tuple' object has no attribute 'append'
5. ('D', 'a', 'l', 'l', 'a', 's') vs ('Dallas',)
Common Python tuple function errors: an int, two arguments, item assignment, append and a string
Four errors and one surprise.
  1. Use (2026,).
  2. Pass one iterable.
  3. Build a new tuple.
  4. Use a list to append.
  5. Use ("Dallas",).

Need to add items anyway? Read how to append to a tuple in Python.

Wrapping Up the Python tuple() Function

Python’s tuple() function turns any iterable into a fixed, ordered sequence. Use it to freeze lists, make dictionary keys and collect generator results.

Next, browse more Python built-in functions and methods.

Keep practicing with tuples here:

Quick Answers on Python tuple() Function

Is tuple() faster than a list?

It uses a little less memory than a list, but pick based on whether the data should change.

What is the difference between tuple() and parentheses?

(1, 2) is a literal. tuple() converts an existing iterable.

Does tuple() make a deep copy?

No. It’s shallow, so a list inside the tuple can still change.

Can a tuple be a dictionary key if it holds a list?

No. Every item must be hashable, so (1, [2]) raises a TypeError.

Where can I read the full tuple() reference?

The signature and constructor rules are in tuple() in the Python docs.