题解 | #合法IP#
合法IP
https://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
ip = input().strip().split('.')
if len(ip) != 4:
print("NO")
else:
is_legal = True
for i in ip:
if not i.isnumeric():
is_legal = False
break
elif len(i) > 3:
is_legal = False
break
elif len(i) > 1 and i[0] == '0':
is_legal = False
break
elif int(i) < 0 or int(i) > 255:
is_legal = False
break
if is_legal:
print("YES")
else:
print("NO")

