题解 | #合法IP#
合法IP
https://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
ip1 = list(input().split('.')) #print(ip1) ip2 = [] flag = 0 #print(ip1) for i in ip1: if i == '': flag = 0 break elif i[0] == '0' and len(i) >= 2: flag = 0 break elif len(ip1) != 4: flag = 0 break elif not i.isdigit(): flag = 0 break else: ip2 = list(map(int, ip1)) for i in ip2: if 0 <= i <= 255: flag = 1 else: flag = 0 break if flag == 0: print('NO') else: print('YES')