Intermediate Python

Validate IPv4 Address

In a world where networks and connections are everywhere, validating IP addresses becomes a common task. An IP address is a label assigned to a device connected to a computer network. The most common version of an IP address is IPv4. Your task is to create a program that validates IPv4 addresses.
A valid IPv4 address consists of four numbers separated by periods. Each number should not exceed 255.
The input contains a single line with a string s that represents the potential IP address.
The program should output VALID if the provided string is a valid IPv4 address, and INVALID otherwise.
Note: The numbers in an IPv4 address cannot have leading zeros. For example, the address "" is considered INVALID.


Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue