def prompt_for_ip():
    """
    Prompt the user to enter an IP address or "quit" to terminate the sample.
    Any IP address the user enters is validated using the ipaddress module. If
    the user entered an IP address the IP address string is returned, otherwise
    None is returned.
    """

    ip = None
    while ip is None:

        ip = input(
            "Enter an IP address, or quit to terminate the sample: ").strip()

        if ip == "quit":
            return None

        # Use Python's ipaddress module to validate the IP address.
        try:
            parsed_ipaddress = ipaddress.ip_address(ip)
            ip = str(parsed_ipaddress)
        except __HOLE__ as e:
            print(str(e))
            ip = None

    return ip
dataset/ETHPy150Open ibm-security-intelligence/api-samples/siem/09_GetOffensesForIp.py/prompt_for_ip