Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_valid_IP(string):
- parts = string.split(".")
- if len(parts) != 4:
- print('Ip False')
- return False
- for item in parts:
- if not item.isdigit():
- print('Ip False')
- if len(item) > 1 and item[0] == '0':
- print('Ip False')
- i = int(item)
- if i < 0 or i > 255:
- print('Ip False')
- print('Ip True')
- is_valid_IP('0.0.0.0')
Advertisement
Add Comment
Please, Sign In to add comment