DEV Community

Poopcoder
Poopcoder

Posted on • Originally published at poopcode.com on

Convert a dictionary to a list of tuples in Python

To convert a dictionary to a list of tuples you can pass the dictionary items into list constructor and it would return a list of tuples.

dictionary = {'name': 'Anand', 'age': 30, 'sex': 'Male'}
print(list(dictionary.items()))


#[('age', 30), ('name', 'Anand'), ('sex', 'Male')]

Enter fullscreen mode Exit fullscreen mode

Top comments (0)