Abatoor

Untitled

Dec 12th, 2021
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. def is_valid_IP(string):
  2.  
  3.     parts = string.split(".")
  4.  
  5.     if len(parts) != 4:
  6.         print('Ip False')
  7.         return False
  8.  
  9.  
  10.     for item in parts:
  11.  
  12.         if not item.isdigit():
  13.  
  14.             print('Ip False')
  15.  
  16.         if len(item) > 1 and item[0] == '0':
  17.  
  18.             print('Ip False')
  19.  
  20.  
  21.         i = int(item)
  22.         if i < 0 or i > 255:
  23.  
  24.             print('Ip False')
  25.  
  26.  
  27.     print('Ip True')
  28.  
  29.  
  30.  
  31. is_valid_IP('0.0.0.0')
  32.  
Advertisement
Add Comment
Please, Sign In to add comment