You can use a dict comprehension:

{k: v for k, v in points.items() if v[0] < 5 and v[1] < 5}

And in Python 2, starting from 2.7:

{k: v for k, v in points.iteritems() if v[0] < 5 and v[1] < 5}
Answer from Thomas on Stack Overflow
🌐
LearnPython.com
learnpython.com › blog › filter-dictionary-in-python
How to Filter a Python Dictionary | LearnPython.com
December 26, 2022 - Learn how to filter Python dictionaries by keys and values, including using multiple keys and conditions at once.
Discussions

filter items in a python dictionary where keys contain a specific string - Stack Overflow
I'm a C coder developing something in python. I know how to do the following in C (and hence in C-like logic applied to python), but I'm wondering what the 'Python' way of doing it is. I have a More on stackoverflow.com
🌐 stackoverflow.com
Filtering a dictionary value from a list of dictionary using lambda and filter in python - Stack Overflow
I want to get the value of the dictionary that has the key 'Name' Initially I wrote a function as below: def get_json_val(l, key): for item in l: for k, v in item.iteritems(): if k == key: return v · But I want to do it using lambdas and filter in a single line. More on stackoverflow.com
🌐 stackoverflow.com
January 11, 2018
Filtering a nested (default) dict based on values
new_filtered_dict = {} for k, d in your_dict.items(): filtered = {word: count for word, count in d.items() if count >= 2} # subfiltering on count value if filtered: # filtering on having any items after subfilter new_filtered_dict[k] = filtered More on reddit.com
🌐 r/learnpython
1
1
January 28, 2022
How to filter dictionary by value?
Use dictionary comprehensions. They work pretty much the same as list comprehensions and generator expressions. filtered_dict = {key: value for key, value in old_dict.iteritems() if value > 90} More on reddit.com
🌐 r/learnpython
10
12
December 10, 2013
🌐
w3resource
w3resource.com › python-exercises › dictionary › python-data-type-dictionary-exercise-42.php
Python: Filter a dictionary based on values - w3resource
June 28, 2025 - Write a Python program to use a lambda function in dictionary comprehension to keep only key-value pairs satisfying a condition. Write a Python program to create a new dictionary by removing entries whose values do not meet a specified predicate.
🌐
Finxter
blog.finxter.com › home › learn python blog › how to filter a dictionary in python? (… the most pythonic way)
How to Filter a Dictionary in Python? (... The Most Pythonic Way) - Be on the Right Side of Change
October 9, 2022 - The lambda function you pass returns k%2 == 1 which is the Boolean filtering value associated with each original element in the dictionary names. Similarly, if you want to filter by key to include only even keys, do the following:
🌐
AskPython
askpython.com › python › dictionary › filter-list-of-dictionaries-based-on-key-values
3 Ways to Filter List of Dictionaries Based on Key Values - AskPython
April 27, 2023 - A new list called filteredlist is created to store the list obtained from filtering the dictionary using the filter method. The lambda function is used to check through every age item in the dictionary and verify if it is greater than the threshold.
🌐
Sololearn
sololearn.com › en › Discuss › 3283767 › filter-and-lambda-expressions-with-dictionaries-update-answered
Filter and lambda expressions with dictionaries. Update: Answered | Sololearn: Learn to code for FREE!
July 9, 2024 - but we can use the membership operator `in`. to get it done we can filter for the letter `a` like: ... k_names = dict(filter(lambda item: 'a' in item[1], figures.items())) > result will be: {'chicken': 'Klaartje', 'horse': 'Karel', 'duck': 'Donald'} >> to make the filtering with the dicts a bit more general, we can use input values, store them in a variable,and use this variable instead of the *hardcoded* samples we have been talking so far. ... if you are looking for more complex patterns than startswith(), endswith(), and "in", consider "regular expressions" (not sure if it is covered in the current courses?). ... Lisa , regex is *not* explained in the current available python tutorials.
🌐
GeeksforGeeks
geeksforgeeks.org › python-filter-dictionaries-by-values-in-kth-key-in-list
Python – Filter dictionaries by values in Kth Key in list | GeeksforGeeks
March 31, 2023 - Use map() to apply the lambda function to each dictionary in test_list and store the result in a list. Use filter() to filter the dictionaries in the list based on whether d[K] is in search_list.
Find elsewhere
🌐
GitHub
gist.github.com › 89465127 › 5776892
python filter a dictionary by keys or values · GitHub
@fbens iteritems is gone if you're using python 3. try d.items() instead · Copy link · Copy Markdown · can use this for value search d3 = {k : v for k,v in filter(lambda t: t[1] in [22, 33], d.iteritems())} Sign up for free to join this conversation on GitHub.
🌐
GeeksforGeeks
geeksforgeeks.org › python-filter-dictionary-values-in-heterogeneous-dictionary
Python - Filter dictionary values in heterogeneous dictionary - GeeksforGeeks
May 9, 2024 - Initialize a variable K with a value of 3. Use the filter() function to filter the items in the test_dict dictionary using a lambda function.
🌐
HackerNoon
hackernoon.com › filtering-dictionary-in-python-3-3eb99f92e6ee
Filtering Dictionary In Python 3
Discover Anything · Hackernoon · Signup · Write · Light-Mode · Classic · Newspaper · Minty · Dark-Mode · Neon Noir
🌐
datagy
datagy.io › home › python functions › python filter: a complete guide to filtering iterables
Python filter: A Complete Guide to Filtering Iterables • datagy
December 20, 2022 - In this tutorial, you’ll learn how to use the filter() function to filter items that meet a condition. You’ll learn how to use the function to filter lists, tuples, and dictionaries.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-extract-filtered-dictionary-values
Python | Extract filtered Dictionary Values - GeeksforGeeks
April 23, 2023 - Method #3 : Using filter() and lambda This method uses the filter() function along with a lambda function to filter the values of the dictionary. It is similar to using a list comprehension, but may be more readable to some users.
🌐
Python Guides
pythonguides.com › python-dictionary-filter
How to Filter a Dictionary in Python
November 10, 2025 - Learn how to filter a dictionary in Python using conditions, dictionary comprehensions, and lambda functions. Includes clear examples and practical tips.
🌐
GeeksforGeeks
geeksforgeeks.org › python › filter-list-of-dictionaries-based-on-key-values-in-python
Filter List of Dictionaries Based on Key Values in Python - GeeksforGeeks
July 23, 2025 - p = [{'name': 'geek1', 'role': ... # Use filter() with lambda to filter the list based on roles res = list(filter(lambda d: d['role'] in f, p)) print(res) ......
🌐
GeeksforGeeks
geeksforgeeks.org › python › filter-list-of-python-dictionaries-by-key-in-python
Filter List of Python Dictionaries by Key in Python - GeeksforGeeks
July 23, 2025 - Let's explore some more methods and see how we can filter list of Python dictionaries by key in Python. ... filter() function can also be used to filter dictionaries based on a key. This method requires converting the result to a list. ... people = [ {"name": "Coco", "age": 25}, {"name": "Kate", "age": 30}, {"name": "Charlie", "age": 35}, {"name": "David", "age": 40} ] filtered_people = list(filter(lambda p: p["age"] > 30, people)) print(filtered_people)
🌐
Medium
medium.com › @muirujackson › set-dictionary-and-lambda-filter-reduce-and-map-functions-4b304a30a0da
Set, Dictionary, and Lambda, filter, reduce and map functions | by Muiru Jackson | Medium
June 14, 2023 - In this article, we explored sets and their methods, compared sets with lists, learned how to iterate over sets, discussed dictionaries and their advantages, and delved into lambda functions, map, reduce, and filter functions. These concepts are essential for any Python programmer looking to work with different data structures efficiently and leverage powerful functions to simplify coding tasks. By understanding these topics, you can enhance your Python skills and become more proficient in writing clean and effective code.
🌐
EyeHunts
tutorial.eyehunts.com › home › python filter dictionary
Python filter dictionary - Tutorial - By EyeHunts
January 10, 2023 - dictOfNames = { 1: 'Tim K', 2: 'John T', 3: 'Mike O', 4: 'Sam', 5: 'Ryan', 6: 'Kik' } def filterTheDict(dictObj, callback): newDict = dict() # Iterate over all the items in dictionary for (key, value) in dictObj.items(): # Check if item satisfies the given condition then add to new dict if callback((key, value)): newDict[key] = value return newDict newDict = filterTheDict(dictOfNames, lambda elem: len(elem[1]) == 6) print('Filtered Dictionary : ') print(newDict)
🌐
Reddit
reddit.com › r/learnpython › filtering a nested (default) dict based on values
r/learnpython on Reddit: Filtering a nested (default) dict based on values
January 28, 2022 -

Hello.

I've gotten some help from redditors on a very similar problem before, but I've modified the problem slightly.

I have a nested defaultdict, the structure of which is {'source_word_string':{'target_word_string':frequency_int}}. When (pretty) printed, it looks like this:

defaultdict(<function <lambda> at 0x10948ee50>,
            {'around': defaultdict(<class 'int'>, {'autour-de': 1}),
             'from': defaultdict(<class 'int'>, {'en': 1}),
             'in-front-of': defaultdict(<class 'int'>, {'devant': 1}),
             'on': defaultdict(<class 'int'>, {'sur': 2, 'au-bord-d’': 1}),
             'to': defaultdict(<class 'int'>, {'en': 1, 'à':3}),
             'under': defaultdict(<class 'int'>, {'sous': 1})})

I would like to delete all source-target word pairs whose frequency count is less than 2.

I would thus expect as output:

defaultdict(<function <lambda> at 0x108c57e50>,             
    {'on': defaultdict(<class 'int'>, {'sur': 2}),
    {'to': defaultdict(<class 'int'>, {'à': 3})}) 

I think I need to do two nested loops (over source words and over target words) and then write to a new filtered_dict, but I'm not sure what that looks like in practice.

Any help would be greatly appreciated. Thank you in advance.