题解 | #合法IP#
合法IP
https://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
while 1: try: ip = input().split('.') counter = 0 if len(ip) != 4: print('NO') break else: for i in range(4): if not ip[i].isdigit(): print('NO') break elif int(ip[i]) > 255 or int(ip[i]) <0 or (len(ip[i]) > 1 and ip[i][0] == '0'): print('NO') break counter += 1 if counter == 4: print('YES') except: break