5
votes

How can I transform tuple like this:


(
    ('a', 1),
    ('b', 2)
)

to dict:


{
    'a': 1,
    'b': 2
}
1
Shouldn't you select the (one and only ATM) answer as your preferred answer? - tzot

1 Answers

16
votes

Dict constructor can do this for you.

dict((
    ('a', 1),
    ('b', 2)
))