Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Verify the accuracy of a input subnet mask
- while True:
- alw = [255, 254, 252, 248, 240, 224, 192, 128, 0]
- mask = raw_input('Enter the subnet mask: ')
- m = mask.split('.')
- if len(m) !=4 or (int(m[0]) !=255 or (int(m[1]) or int(m[2]) or int(m[3])) not in alw) :
- print 'Error: this is not a subnet mask\n'
- continue
- '''
- # Is it the right condition ?
- if int(m[1]) < 255 & int(m[2]) == int(m[3]) == 0:
- pass
- if int(m[1]) == 255 & int(m[2]) < 255 & int(m[3]) == 0:
- pass
- if int(m[1]) == int(m[2]) == 255 & int(m[3]) < 255 :
- pass
- '''
- # Why It doesn't work as well?
- 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) \
- & (int(m[1]) != int(m[2]) != 255 or int(m[3]) >= 255):
- continue
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement