---
title: What Is a Tuple in Python Programming?
description: In Python, a tuple is a data type closely related to the list. In this blog post, learn about the tuple in Python development?
image: https://blog.rheinwerk-computing.com/hubfs/What%20Is%20a%20Tuple%20in%20Python%20Programming.png
---

[![Rheinwerk Computing Logo](https://blog.rheinwerk-computing.com/hubfs/computing_logo-header.svg)](https://blog.rheinwerk-computing.com/) [Blog](https://blog.rheinwerk-computing.com)

- Books 
    - Get an overview of our wide selection of books on every relevant computing topic. 
          - [General Computing](https://www.sap-press.com/rheinwerk-computing/general-computing/)
          - [DevOps](https://www.sap-press.com/rheinwerk-computing/devops/)
          - [Programming Languages](https://www.sap-press.com/rheinwerk-computing/programming-languages/)
          - [Security](https://www.sap-press.com/rheinwerk-computing/security/)
          - [Software Development](https://www.sap-press.com/rheinwerk-computing/software-development/)
- Book Subscription 
    - Get unlimited access to all Rheinwerk Computing books! 
          - [Programming Subscription](https://sap-press.com/subscriptions/)

[What Is?](https://blog.rheinwerk-computing.com/tag/what-is)

# What Is a Tuple in Python Programming?

![Rheinwerk Computing](https://blog.rheinwerk-computing.com/hubfs/RW-logo-300x300.png)  by [Rheinwerk Computing](https://blog.rheinwerk-computing.com/author/rheinwerk-computing)

In Python, a *tuple* is a data type closely related to the list, a very flexible sequential data type that can accommodate arbitrarily long sequence of elements.

 

Unlike the list, the tuple is immutable, which opens the possibility of calculating *hash values* for tuples. This property is important for the use of tuples in combination with data types like the dictionary or the set, which are based on hash tables. Based on the condition that hash values can also be calculated for all elements of a tuple, it may therefore be used as a key in a dictionary or as an element in a set, which differentiates it from a list.

 

The concept of a tuple is related to that of the list, but due to its immutability, only the basic set of operations for sequential data types is available for tuple instances.

 

To create new tuple instances, you must use the parentheses, which—like lists—contain the elements of the tuple, separated by commas:

 

`>>> a = (1, 2, 3, 4, 5)`

`>>> a[3]`

`4`

 

An empty tuple is defined by two parentheses () without content. A special case involves tuples with only one element. If you try to create a tuple with only one element in the way described previously, the program will behave differently than intended:

 

`>>> no_tuple = (2)`

`>>> type(no_tuple)`

`<class 'int'>`

 

With (2), no new tuple instance is created because the parentheses are already used in this context for arithmetic operations with integers. Hence tuple literals containing only a single element are written with an additional comma after the element:

 

`>>> a_tuple = (2,)`

`>>> type(a_tuple)`

`<class 'tuple'>`

## Packing and Unpacking

You can omit the enclosing parentheses in a tuple definition. Nevertheless, the references separated by commas are combined into a tuple, which is referred to as *tuple packing* or, more simply, *packing*:

 

`>>> date = 7, 26, 1987`

`>>> date`

`(7, 26, 1987)`

 

Conversely, it’s also possible to *unpack* the values of a tuple:

 

`>>> date = 7, 26, 1987`

`>>> (month, day, year) = date`

`>>> month`

`7`

`>>> day`

`26`

`>>> year`

`1987`

 

This process is referred to as *tuple unpacking* or simply *unpacking*, and again the parentheses can be omitted. By combining packing and unpacking, you can very elegantly swap the values of two variables without a helper variable or combine several assignments in one line:

 

`>>> a, b = 10, 20`

`>>> a, b = b, a`

`>>> a`

`20`

`>>> b`

`10`

 

Unpacking is not limited to the tuple data type, but works for sequential data types in general. In this case, the term *sequence unpacking* is also commonly used:

 

`>>> a, b, c = "abc"`

`>>> a`

`'a'`

 

If applied properly, the use of this feature can contribute to the readability of programs as the technical detail of caching data moves to the background of the actual intent of swapping values.

 

Unpacking can also be used to read values at the beginning and end of a sequence. Let's consider the following example:

 

`>>> numbers = [11, 18, 12, 15, 10]`

`>>> eleven, *others, ten = numbers`

`>>> eleven`

`11`

`>>> ten`

`10`

`>>> others`

`[18, 12, 15]`

 

If an asterisk (\*) is prefixed to a reference when unpacking, all other values of the sequence are stored in it. In the preceding example, the first value of numbers is stored in eleven and the last value in ten. The numbers in between are collected into others.

 

Any number of other references may precede and follow the asterisked entry. In particular, the first or last entry can have an asterisk:

 

`>>> numbers = [11, 17, 17, 19, 10]`

`>>> *something, nineteen, ten = numbers`

`>>> nineteen`

`19`

`>>> ten`

`10`

`>>> eleven, *blah_blah_blah = numbers`

`>>> eleven`

`11`

`>>> blah_blah_blah`

`[17, 17, 19, 10]`

 

There can always only be exactly one reference with an asterisk in an assignment with unpacking. This makes sense, as otherwise ambiguities can arise.

 

In general, you should be careful when using unpacking for unordered data types. In the following example, the order of the elements 1, 2, and 3 depends on the order in which the set {3,1,2} is iterated over:

 

`>>> a, b, c = {3, 1, 2}`

`>>> a, b, c`

`(1, 2, 3)`

 

Because this order is an implementation detail, it may differ between different versions of [Python](https://learning.rheinwerk-computing.com/python), or even between different runs of the same program.

 

## Immutable Doesn’t Necessarily Mean Unchangeable!

Although tuple instances are immutable, the values of the elements contained during their generation may change. When a new tuple is created, the references it is to store are specified. If such a reference points to an instance of a mutable data type, such as a list, its value can still change:

 

`>>> a = ([],)`

`>>> a[0].append("And yet it moves!")`

`>>> a`

`(['And yet it moves!'],)`

 

The immutability of a tuple thus refers only to the references it contains and explicitly not to the instances behind it.

 

Thus, the fact that tuples are immutable is no guarantee that elements won’t change once the tuple has been created.

 

*Editor’s note*: This post has been adapted from a section of the book [*Python 3: The Comprehensive Guide*](https://www.amazon.com/Python-Comprehensive-Hands-Programming-Rheinwerk/dp/1493228005?maas=maas_adg_3257CC065CA6532EA40D4F757AAF33F9_afap_abs&ref_=aa_maas&tag=maas)by [Johannes Ernesti](https://www.linkedin.com/in/johannes-ernesti-775442176/) and [Peter Kaiser](https://www.linkedin.com/in/peter-kaiser-3a940a152/). Johannes is a research scientist at DeepL. He is a graduate mathematician and received his doctorate in applied mathematics from the Karlsruhe Institute of Technology (KIT). Peter is a research scientist at DeepL. He has a degree in computer science and received a doctorate in humanoid robotics from the Karlsruhe Institute of Technology (KIT). 

 

This post was originally published 3/2023.

## Recommendation

[![Your All-in-One Guide to Python](https://blog.rheinwerk-computing.com/hs-fs/hubfs/2800_2d.png?width=170&name=2800_2d.png)](https://www.amazon.com/Python-Comprehensive-Hands-Programming-Rheinwerk/dp/1493228005?maas=maas_adg_3257CC065CA6532EA40D4F757AAF33F9_afap_abs&ref_=aa_maas&tag=maas)

**Your All-in-One Guide to Python!**

This award-winning guide covers everything you need to write effective Python — from core concepts like functions, data types, and object orientation to advanced topics like GUIs, Django, network programming, and scientific computing. Whether you're picking up Python for the first time or leveling up your skills, it's a hands-on reference you'll keep coming back to.

[Learn More](https://www.amazon.com/Python-Comprehensive-Hands-Programming-Rheinwerk/dp/1493228005?maas=maas_adg_3257CC065CA6532EA40D4F757AAF33F9_afap_abs&ref_=aa_maas&tag=maas)

![Rheinwerk Computing](https://blog.rheinwerk-computing.com/hubfs/RW-logo-300x300.png)

**by [Rheinwerk Computing](https://blog.rheinwerk-computing.com/author/rheinwerk-computing)**

Rheinwerk Computing is an imprint of Rheinwerk Publishing and publishes books by leading experts in the fields of programming, administration, security, analytics, and more.

[What Is?](https://blog.rheinwerk-computing.com/tag/what-is) [Python](https://blog.rheinwerk-computing.com/tag/python) [Programming Languages](https://blog.rheinwerk-computing.com/tag/programming-languages)

[![Share on facebook](https://7528309.fs1.hubspotusercontent-na1.net/hub/7528309/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/facebook-color.png?width=24&name=facebook-color.png)](https://www.facebook.com/share.php?u=https%3A%2F%2Fblog.rheinwerk-computing.com%2Fwhat-is-a-tuple-in-python-programming%3Futm_medium%3Dsocial%26utm_source%3Dfacebook) [![Share on linkedin](https://7528302.fs1.hubspotusercontent-na1.net/hub/7528302/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/linkedin-color.png?width=24&name=linkedin-color.png)](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fblog.rheinwerk-computing.com%2Fwhat-is-a-tuple-in-python-programming%3Futm_medium%3Dsocial%26utm_source%3Dlinkedin) [![Share on twitter](https://7528304.fs1.hubspotusercontent-na1.net/hub/7528304/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/twitter-color.png?width=24&name=twitter-color.png)](https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fblog.rheinwerk-computing.com%2Fwhat-is-a-tuple-in-python-programming%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&url=https%3A%2F%2Fblog.rheinwerk-computing.com%2Fwhat-is-a-tuple-in-python-programming%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&source=tweetbutton&text=) [![Share on email](https://7528311.fs1.hubspotusercontent-na1.net/hub/7528311/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/email-color.png?width=24&name=email-color.png)](mailto:?subject=Check+out+https%3A%2F%2Fblog.rheinwerk-computing.com%2Fwhat-is-a-tuple-in-python-programming%3Futm_medium%3Dsocial%26utm_source%3Demail&body=Check+out+https%3A%2F%2Fblog.rheinwerk-computing.com%2Fwhat-is-a-tuple-in-python-programming%3Futm_medium%3Dsocial%26utm_source%3Demail)

### Comments

### Latest Blog Posts

[![What Is the Basic Structure of a Python Program?](https://blog.rheinwerk-computing.com/hs-fs/hubfs/What%20Is%20the%20Basic%20Structure%20of%20a%20Python%20Program.png?height=600&name=What%20Is%20the%20Basic%20Structure%20of%20a%20Python%20Program.png)](https://blog.rheinwerk-computing.com/what-is-the-basic-structure-of-a-python-program)

[What Is?](https://blog.rheinwerk-computing.com/tag/what-is)

## [What Is the Basic Structure of a Python Program?](https://blog.rheinwerk-computing.com/what-is-the-basic-structure-of-a-python-program)

[Read More](https://blog.rheinwerk-computing.com/what-is-the-basic-structure-of-a-python-program)

[![How to Create Your First Python Program](https://blog.rheinwerk-computing.com/hs-fs/hubfs/How%20to%20Create%20Your%20First%20Python%20Program.png?height=600&name=How%20to%20Create%20Your%20First%20Python%20Program.png)](https://blog.rheinwerk-computing.com/how-to-create-your-first-python-program)

[Python](https://blog.rheinwerk-computing.com/tag/python)

## [How to Create Your First Python Program](https://blog.rheinwerk-computing.com/how-to-create-your-first-python-program)

[Read More](https://blog.rheinwerk-computing.com/how-to-create-your-first-python-program)

**Subscribe to our blog!**Get notified about future blog updates.

- <https://www.linkedin.com/showcase/rheinwerk-computing/>
- <https://www.youtube.com/channel/UChj-U-uWGM7qRlHXSFU93ew>
- <https://blog.rheinwerk-computing.com/rss.xml>

### The official Rheinwerk Computing Blog

Rheinwerk Computing is an imprint of Rheinwerk Publishing and publishes resources that will help you accelerate your computing journey. The Rheinwerk Computing Blog is designed to provide helpful, actionable information on a variety of topics, including programming, administration, security, and analytics!

### Blog Topics

- [All Topics](https://blog.rheinwerk-computing.com)
- [Programming Languages](https://blog.rheinwerk-computing.com/tag/programming-languages)
- [How To](https://blog.rheinwerk-computing.com/tag/how-to)
- [JavaScript](https://blog.rheinwerk-computing.com/tag/javascript)
- [DevOps](https://blog.rheinwerk-computing.com/tag/devops)
- [Featured](https://blog.rheinwerk-computing.com/tag/featured)
- [Web Development](https://blog.rheinwerk-computing.com/tag/web-development)
- [What Is?](https://blog.rheinwerk-computing.com/tag/what-is)
- [Cybersecurity](https://blog.rheinwerk-computing.com/tag/cybersecurity)
- [Artificial Intelligence](https://blog.rheinwerk-computing.com/tag/artificial-intelligence)
- [Software Development](https://blog.rheinwerk-computing.com/tag/software-development)

### Blog curated by

[![Rheinwerk Computing Logo](https://blog.rheinwerk-computing.com/hubfs/computing_logo-header.svg)](https://www.sap-press.com/rheinwerk-computing/) [Visit Rheinwerk Computing Store](https://www.sap-press.com/rheinwerk-computing/)

### About

- [Home](https://sap-press.com/)
- [About Us](https://sap-press.com/the-publisher/)
- [Contact](mailto:info@rheinwerk-publishing.com)
- [Legal Notes](https://sap-press.com/legal-notes/)
- [Privacy Policy](https://sap-press.com/privacy/)
- [Terms of Use](https://sap-press.com/terms/)

© 2026 Rheinwerk Publishing, Inc. | Change Privacy Options

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Rheinwerk Computing",
    "url" : "https://blog.rheinwerk-computing.com/author/rheinwerk-computing"
  },
  "dateModified" : "2026-08-28T14:10:34.378Z",
  "datePublished" : "2023-03-20T13:00:00.000Z",
  "headline" : "What Is a Tuple in Python Programming?",
  "image" : [ "https://blog.rheinwerk-computing.com/hubfs/What%20Is%20a%20Tuple%20in%20Python%20Programming.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.rheinwerk-computing.com/what-is-a-tuple-in-python-programming",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.rheinwerk-computing.com/hubfs/Logo-1.jpg"
    },
    "name" : "Rheinwerk Publishing, Inc."
  }
}
```