Skip to content

Home

Dictionary to list

Converts a dictionary to a list of tuples.

def dict_to_list(d):
  return list(d.items())

d = {'one': 1, 'three': 3, 'five': 5, 'two': 2, 'four': 4}
dict_to_list(d)
# [('one', 1), ('three', 3), ('five', 5), ('two', 2), ('four', 4)]

More like this

Start typing a keyphrase to see matching snippets.