Sergey
Sergey

Reputation: 51

Transform tuple to dict

How can I transform tuple like this:


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

to dict:


{
    'a': 1,
    'b': 2
}

Upvotes: 5

Views: 492

Answers (1)

Manoj Govindan
Manoj Govindan

Reputation: 74705

Dict constructor can do this for you.

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

Upvotes: 16

Related Questions