Python Tuple Operations
Python Tuple is an immutable collection of items. Also, tuple is an ordered collection. These properties of a tuple enable some operations like accessing the items using an index, iterating over its elements, etc., and disable some of the operations like updating tuple items.
In this tutorial, we will go through some of the commonly used Tuple operations in Python programming.
List of all Tuple Operations
Following are the list of tuple operations that we can perform in Python. Each of these tutorial provide well detailed examples to understand each operation.
- Tuple – Detailed tutorial on what a tuple is?
- Create Tuple – Different ways to create a Tuple.
- Empty Tuple – No items in Tuple
- Tuple Length – Find the number of elements in a tuple.
- Access Tuple – Access items of tuple using index or loop.
- Iterate over Tuple items using For Loop
- Iterate over Tuple items using While Loop
- Update Tuple Items – A workaround, since tuple is immutable.
- Check if Item is in Tuple
- Reverse Tuple using reversed()
- List of Tuples – Tutorial on how to create a list of tuples in Python. The list will contain tuples as elements.
- Sort List of Tuples – We have a list of tuples, and the tutorial helps on how to sort these list of tuples.
- Tuple vs List – Differences between a Tuple and List in Python.
- Return Tuple from Function – How to return a Tuple from a Function.
- Convert Tuple to List – Tutorial on how to convert a Tuple into a List.
- Convert List to Tuple – Tutorial on how to convert a List into a Tuple.
- Convert Tuple to String – Tutorial on how how to convert a Tuple into a String.
- Python – Slice a Tuple
In this tutorial of Python Examples, we learned how to use Tuple in a Python program with different usages of tuple presented as examples and tutorials.