Python Ordered Dictionary to regular Dictionary -
i have like
[('first', 1), ('second', 2), ('third', 3)]
and want built in function make like
{'first': 1, 'second': 2, 'third': 3}
is aware of built-in python function provides instead of having loop handle it?
needs work python >= 2.6
dict
can take list of tuples , convert them key-value pairs.
>>> lst = [('first', 1), ('second', 2), ('third', 3)] >>> dict(lst) {'second': 2, 'third': 3, 'first': 1}
Comments
Post a Comment