Skip to content

Convert a dictionary to a list of tuples in Python

Advertisements

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

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

See also  Python code snippet - How to check if value is in list ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.