i.e-
(
(1, 'Pending'),
(2, 'Done'),
(3, 'Cancel')
)
In this article, we'll show you how to convert a Python tuple to a dictionary. We can use dict(tuple)
to convert tuple to dictionary.
Example -
# input tuple
Tuple = ((1, 'Pending'),(2, 'Done'),(3, 'Cancel'))
print("The Tuple:",Tuple )
Dictionary = dict(Tuple)print("The Dictionary:",Dictionary )
The input Tuple: (1, 'Pending'),(2, 'Done'),(3, 'Cancel')
The result dictionary: {1:'Pending',2:'Done',3:'Cancel')}