def is_valid_ip_prefix(prefix, bits):
 try:
  prefix = int(prefix)
 except ValueError:
  return False
 return (0 <= prefix <= bits)

def is_valid_ip_prefix ( prefix , bits ) : try : prefix = int ( prefix ) except ValueError : return False return ( 0 <= prefix <= bits )
returns true if *prefix* is a valid ipv4 or ipv6 address prefix .