mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-11 00:59:49 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
ba356ca4b4
commit
0f3c63319d
@ -51,25 +51,25 @@ def is_ip_v4_address_valid(ip: str) -> bool:
|
|||||||
False
|
False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parts = ip.split('.')
|
parts = ip.split(".")
|
||||||
|
|
||||||
if len(parts) != 4:
|
if len(parts) != 4:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for part in parts:
|
for part in parts:
|
||||||
if not part:
|
if not part:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for i in range(len(part)):
|
for i in range(len(part)):
|
||||||
if not part[i].isdigit():
|
if not part[i].isdigit():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if part[0] == '0' and len(part) > 1:
|
if part[0] == "0" and len(part) > 1:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not (0 <= int(part) <= 255):
|
if not (0 <= int(part) <= 255):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user