
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How can I use Multiple-tuple in Python?
A multiple tuple is a tuple of tuples.
example
((0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11), (12, 13, 14))
You can iterate over a multiple tuple using the python destructuring syntax in the following way
x = ((0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11), (12, 13, 14)) for a, b, c in x: print(a + b + c)
Output
This will give the output
3 12 21 30 39
This structure is useful when you want to return a structure that has defined order and you want it to be immutable.
- Related Articles
- How we can use Python Tuple within a Tuple?
- How can I append a tuple into another tuple in Python?
- How can I do Python Tuple Slicing?
- How can I subtract tuple of tuples from a tuple in Python?
- How can I represent python tuple in JSON format?
- How can I convert Python strings into tuple?
- How can I use Python regex to split a string by multiple delimiters?
- How can I define duplicate items in a Python tuple?
- How I can dump a Python tuple in JSON format?
- How can I convert Python tuple to C array?
- How can I create a non-literal python tuple?
- How I can convert a Python Tuple into Dictionary?
- How can I convert a Python tuple to string?
- How can I use multiple submit buttons in an HTML form?
- How can I create a Python tuple of Unicode strings?

Advertisements