Using a simple list comprehension (if you’re sure every dictionary has the key):
In [10]: [d['key'] for d in l]
Out[10]: [1, 2, 3]
Otherwise you’ll need to check for existence first:
In [11]: [d['key'] for d in l if 'key' in d]
Out[11]: [1, 2, 3]
More Related Contents:
- How to name a file using a value in a list in a dictionary?
- How do I sort a list of dictionaries by a value of the dictionary?
- Access nested dictionary items via a list of keys?
- Why can’t I use a list as a dict key in python?
- How can I get list of values from dict?
- How do I merge a list of dicts into a single dict?
- Grouping Python dictionary keys as a list and create a new dictionary with this list as a value
- Getting a list of values from a list of dicts
- How do I initialize a dictionary of empty lists in Python?
- Pandas DataFrame to List of Dictionaries
- Creating a list of dictionaries results in a list of copies of the same dictionary
- python filter list of dictionaries based on key value
- How can I make a dictionary from separate lists of keys and values?
- How to convert list of key-value tuples into dictionary?
- Merging dictionary value lists in python
- join two lists of dictionaries on a single key
- 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
- Using a dict to translate numbers to letters in python
- How can I make a dictionary (dict) from separate lists of keys and values?
- Changing one dict changes all dicts in a list of dicts [duplicate]
- Appending to list in Python dictionary [duplicate]
- Creating a dictionary with list of lists in Python
- Python Accessing Values in A List of Dictionaries
- How to extract all values from a dictionary in Python?
- Comparing 2 lists consisting of dictionaries with unique keys in python