>>> d = { 'a': 1, 'b': 2, 'c': 3 }
>>> list(d.items())
[('a', 1), ('c', 3), ('b', 2)]
For Python 3.6 and later, the order of the list is what you would expect.
In Python 2, you don’t need list
.
More Related Contents:
- How do I convert two lists into a dictionary?
- Convert [key1,val1,key2,val2] to a dict?
- Why can’t I use a list as a dict key in python?
- Remove duplicate dict in list in Python
- How can I get list of values from dict?
- Getting a list of values from a list of dicts
- list to dictionary conversion with multiple values per key?
- How to overcome TypeError: unhashable type: ‘list’
- Creating a list of dictionaries results in a list of copies of the same dictionary
- How can I make a dictionary from separate lists of keys and values?
- How to convert list of key-value tuples into dictionary?
- Check if value already exists within list of dictionaries?
- Convert list into a dictionary [duplicate]
- Combining Dictionaries Of Lists In Python
- Most Pythonic Way to Build Dictionary From Single List
- Python – sum values in dictionary
- Python: get a dict from a list based on something inside the dict
- Make dictionary from list with python [duplicate]
- how to convert list of dict to dict
- How do I return dictionary keys as a list in Python?
- Why can’t I use a list as a dict key in python? Exactly what can and cannot be used, and why?
- convert csv file to list of dictionaries
- Appending to list in Python dictionary [duplicate]
- Getting the difference (delta) between two lists of dictionaries
- Python: iterating over list vs over dict items efficiency
- Mapping dictionary value to list
- How to sort a list of dictionaries by a value of the dictionary in Python?
- How to extract all values from a dictionary in Python?
- Comparing 2 lists consisting of dictionaries with unique keys in python
- How to create a nested dictionary from a list in Python?