#C6498. IPv4 Address Validator
IPv4 Address Validator
IPv4 Address Validator
You are given a string representing a candidate IPv4 address. Your task is to determine whether the string is a valid IPv4 address.
An IPv4 address is valid if it satisfies the following conditions:
- It consists of exactly four decimal numbers separated by dots.
- Each number is in the range \(0 \leq number \leq 255\).
- Numbers should not contain leading zeros (except when the number itself is 0).
For example, "192.168.1.1" is valid, but "192.168.01.1" is invalid because of the leading zero, and "256.256.256.256" is invalid because 256 is out of range.
You should read the input from standard input and output the result as either True
if the input is a valid IPv4 address, or False
otherwise.
inputFormat
The input consists of a single line containing the IPv4 address candidate as a string.
outputFormat
Output a single line: True
if the IPv4 address is valid, and False
otherwise.
192.168.1.1
True
</p>