0 out of 464 challenges solved
Write a Python function `filter_dict_by_value(data: dict, n: int) -> dict` that takes in a dictionary `data` and an integer `n`. The function should return a new dictionary containing only the key-value pairs from `data` where the value is greater than or equal to `n`. #### Example Usage ```python [main.nopy] input_data = { 'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190 } result = filter_dict_by_value(input_data, 170) print(result) # Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} result = filter_dict_by_value(input_data, 180) print(result) # Output: {'Alden Cantrell': 180, 'Pierre Cox': 190} result = filter_dict_by_value(input_data, 190) print(result) # Output: {'Pierre Cox': 190} ``` #### Constraints - The input dictionary will have string keys and integer values. - The integer `n` will always be a non-negative number.
def filter_dict_by_value(data: dict, n: int) -> dict: """ Filters a dictionary to include only entries with values greater than or equal to n. Args: data (dict): The input dictionary with string keys and integer values. n (int): The threshold value. Returns: dict: A dictionary containing only the key-value pairs where the value is >= n. """ # Write your implementation here pass