题解 | #合法IP#

合法IP

http://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9

def ip(string): if len(string) != 4: return 0 for s in string : if len(s) > 1 and int(s[0]) == 0: return 0 List = list(map(int,string)) for i in List: if i < 0 or i > 255: return 0 return 1 if name == "main": try: string = input().strip().split(".") print("YES" if ip(string) else "NO") except: print("NO")

全部评论

相关推荐

苍蓝星上艾露:这简历。。。可以试试我写的开源简历优化工具https://github.com/weicanie/prisma-ai
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务