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