#K66042. Valid IPv4 Address Checker
Valid IPv4 Address Checker
Valid IPv4 Address Checker
You are given a string representing an IPv4 address. Your task is to determine whether it is a valid IPv4 address. An IPv4 address consists of four decimal numbers, each ranging from 0 to 255, separated by dots (.
). Leading zeros are not allowed (except for the number 0
itself). Formally, if the IPv4 address is represented as \(a.b.c.d\), then each \(a, b, c, d\) must satisfy:
[ 0 \leq a, b, c, d \leq 255 ]
and if a part has more than one digit, it should not start with a zero. For example, 192.168.01.1
is not valid.
inputFormat
The input consists of a single line containing the IPv4 address as a string.
outputFormat
Output a single line containing either True
if the IPv4 address is valid or False
otherwise.
192.168.0.1
True
</p>