0 out of 464 challenges solved
Write a Python function `remove_leading_zeroes(ip: str) -> str` that takes an IP address as a string and removes any leading zeroes from each segment of the address. The function should ensure that the resulting IP address is valid and properly formatted. #### Example Usage ```python [main.nopy] remove_leading_zeroes("216.08.094.196") # Output: "216.8.94.196" remove_leading_zeroes("12.01.024") # Output: "12.1.24" remove_leading_zeroes("216.08.094.0196") # Output: "216.8.94.196" ``` #### Constraints - The input string will always be a valid IPv4 address. - Each segment of the IP address will be a numeric string with possible leading zeroes.
import re def remove_leading_zeroes(ip: str) -> str: """ Removes leading zeroes from each segment of an IP address. Args: ip (str): The input IP address as a string. Returns: str: The IP address with leading zeroes removed. """ # Replace this with the implementation pass