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.