Returns True if *prefix* is a valid IPv4 or IPv6 address prefix.

    *prefix* should be a number between 0 to *bits* length.

def is_valid_ip_prefix(prefix, bits):
    """Returns True if *prefix* is a valid IPv4 or IPv6 address prefix.

    *prefix* should be a number between 0 to *bits* length.
    """
    try:
        # Prefix should be a number
        prefix = int(prefix)
    except ValueError:
        return False

    # Prefix should be a number between 0 to *bits*
    return 0 <= prefix <= bits