Dictionary of tuples with tuples as keys

Here we will pass keys as tuples inside a dictionary

Syntax:

{(tuple1):value,(tuple2):value,.........,(tuple3):value}

Here tuple is a collection of elements that work as a key for some value

Example: Python program to create a dictionary of tuples with a tuple as keys

Python3




# tuple of favourite food as key
# value is name of student
data = {("chapathi", "roti"): 'Bobby'
        ("Paraota", "Idly", "Dosa"): 'ojaswi'}
  
# display
data


Output:

{('Paraota', 'Idly', 'Dosa'): 'ojaswi', ('chapathi', 'roti'): 'Bobby'}

Python – Create Dictionary Of Tuples

In this article, we will discuss how to create a dictionary of tuples in Python.

Similar Reads

Dictionary of tuples with tuples as keys

Here we will pass keys as tuples inside a dictionary...

Dictionary of tuples with tuples as values

...

Create a dictionary from tuples

Here we will pass values as tuples inside a dictionary...