⚑ IT Wisdom A hacker walks into a bar. The bartender asks "What'll it be?" He says "SQL injection -- DROP TABLE drinks;"
Skilled Practitioner
4249 XP 1751 to Expert
Objective: Define a custom exception class and raise it when an IP address fails a basic format check.
Instructions

Create a file called lab3.py. Define a custom exception class called InvalidIPAddress. Write a function called validate_ip(ip) that raises it if the IP does not have exactly 4 dot-separated parts.

Test it against these three IPs:

test_ips = ["192.168.1.1", "10.1.1", "172.16.0.1"]

Your output must match exactly:

192.168.1.1 β€” valid
10.1.1 β€” INVALID
172.16.0.1 β€” valid

Run it with python3 lab3.py. Paste your output below and submit.

πŸ’‘ Show Hint
class InvalidIPAddress(Exception): pass. In validate_ip: split on "." and check len(parts) != 4. Wrap the call in try/except InvalidIPAddress.
Paste Your Output
Next Lab β†’