Queer European MD passionate about IT

numb3rs.py 336 B

12345678910111213141516171819
  1. import re
  2. import sys
  3. def main():
  4. print(validate(input("IPv4 Address: ")))
  5. def validate(ip):
  6. if not re.match(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', ip):
  7. return False
  8. for n in map(int, ip.split('.')):
  9. if not 0 <= n <= 255:
  10. return False
  11. return True
  12. if __name__ == "__main__":
  13. main()