Filter values above 4
Input
filter_dict_by_value({'a': 5, 'b': 2, 'c': 8}, 4)
Output
{'a': 5, 'c': 8}
Only 'a' (5) and 'c' (8) are greater than 4, so they are kept in the result in the same relative order as the input.
Full lesson preview
Filter a dictionary to retain only entries whose values are strictly greater than a given limit.
Problem statement
Task
Examples
Input
filter_dict_by_value({'a': 5, 'b': 2, 'c': 8}, 4)
Output
{'a': 5, 'c': 8}
Only 'a' (5) and 'c' (8) are greater than 4, so they are kept in the result in the same relative order as the input.
Input format
Output format
Constraints
Samples
Input
filter_dict_by_value({'x': 10, 'y': 5, 'z': 0}, 4)
Output
{'x': 10, 'y': 5}
x and y are above 4; z is not.