Python – Create Dictionary from List of Tuples

To create a dictionary from list of tuples in Python, where each tuple is of the form (key, value), pass the list of tuples as argument to dict() builtin function.

dict(list of tuples object)

In this example, we will give a list for tuples as argument to dict() function.

Python Program

iterable = [('m', 4), ('p', 8)]
myDictionary = dict(iterable)
print(myDictionary)
Try Online

Output

{'m': 4, 'p': 8}
ADVERTISEMENT

Conclusion

In this Python Tutorial, we learned how to create a dictionary from a list of tuples using Python dict() builtin function.