题解 | #牛客网的IP地址#
牛客网的IP地址
https://www.nowcoder.com/practice/b4159a20aefa406aaa1bfd7d9739c70c
使用flag作标签,如有非法特征,flag = ‘illegal’,最后print(flag)即可
s = input().split('.') flag = 'legal' if len(s) != 4: flag = 'illegal' else: for i in s: if i: if int(i) > 255 or int(i) < 0: flag = 'illegal' else: flag = 'illegal' print(flag)