IPv4 Format Check
An IPv4 address looks simple, but its format has strict rules. Given a string ip, return True if it is a valid IPv4 address. It must contain exactly four dot-separated numbers, each from 0 to 255, with no leading zeroes and no extra characters. In all other cases, return False.
Примеры
Ввод
"192.168.0.1"Вывод
TrueВвод
"0.0.0.0"Вывод
TrueВвод
"255.255.255.255"Вывод
TrueНужно реализовать
def is_valid_ipv4(ip):
Теги
strings
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
"192.168.0.1"Expected
True2
Input
"0.0.0.0"Expected
True3
Input
"255.255.255.255"Expected
True4
Input
"256.1.1.1"Expected
False5
Input
"1.2.3"Expected
False6
Input
"01.2.3.4"Expected
FalseFocus radio
Paused · SomaFM · Fluid