Advertisement
Guest User

Subnet_mask

a guest
Feb 7th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. # Verify the accuracy of a input subnet mask
  2. while True:
  3. alw = [255, 254, 252, 248, 240, 224, 192, 128, 0]
  4. mask = raw_input('Enter the subnet mask: ')
  5. m = mask.split('.')
  6.  
  7. if len(m) !=4 or (int(m[0]) !=255 or (int(m[1]) or int(m[2]) or int(m[3])) not in alw) :
  8. print 'Error: this is not a subnet mask\n'
  9. continue
  10. '''
  11. # Is it the right condition ?
  12. if int(m[1]) < 255 & int(m[2]) == int(m[3]) == 0:
  13. pass
  14. if int(m[1]) == 255 & int(m[2]) < 255 & int(m[3]) == 0:
  15. pass
  16. if int(m[1]) == int(m[2]) == 255 & int(m[3]) < 255 :
  17. pass
  18. '''
  19. # Why It doesn't work as well?
  20. if (int(m[1]) >= 255 or int(m[2]) != int(m[3]) != 0) & (int(m[1]) != 255 or int(m[2]) >= 255 or int(m[3]) != 0) \
  21. & (int(m[1]) != int(m[2]) != 255 or int(m[3]) >= 255):
  22. continue
  23. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement