def get_net_size(mask):
 binary_str = ''
 for octet in mask.split('.'):
  binary_str += bin(int(octet))[2:].zfill(8)
 return len(binary_str.rstrip('0'))

def get_net_size ( mask ) : binary_str = '' for octet in mask . split ( '.' ) : binary_str += bin ( int ( octet ) ) [ 2 : ] . zfill ( 8 ) return len ( binary_str . rstrip ( '0' ) )
turns an ipv4 netmask into its corresponding prefix length .