0 out of 464 challenges solved
Write a Python function `second_smallest(numbers)` that takes a list of numbers as input and returns the second smallest unique number in the list. If the list does not contain at least two unique numbers, the function should return `None`. #### Example Usage ```python [main.nopy] print(second_smallest([1, 2, -8, -2, 0, -2])) # Output: -2 print(second_smallest([1, 1, -0.5, 0, 2, -2, -2])) # Output: -0.5 print(second_smallest([2, 2])) # Output: None print(second_smallest([2, 2, 2])) # Output: None ``` #### Constraints - The input list can contain integers and floating-point numbers. - The input list can have duplicate values. - The function should handle edge cases, such as an empty list or a list with only one unique number.
def second_smallest(numbers): """ Find the second smallest unique number in a list. Args: numbers (list): A list of numbers (integers or floats). Returns: float or int or None: The second smallest unique number, or None if not applicable. """ # Remove duplicates and sort the list # Check if there are at least two unique numbers # Return the second smallest unique number or None pass