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