{"record":{"id":"d7c812571c836d94","repo":"TheAlgorithms/Python","slug":"invalid-value-for-min-val-or-max-val-min-value","errorCode":null,"errorMessage":"Invalid value for min_val or max_val (min_value < max_value)","messagePattern":"Invalid value for min_val or max_val \\(min_value < max_value\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"other/guess_the_number_search.py","lineNumber":54,"sourceCode":"    >>> temp_input_value(\"ten\",\"fifty\",1)\n    Traceback (most recent call last):\n        ...\n    AssertionError: Invalid type of value(s) specified to function!\n\n    >>> temp_input_value(min_val=-100, max_val=500)\n    -100\n\n    >>> temp_input_value(min_val=-5100, max_val=-100)\n    -5100\n    \"\"\"\n    assert (\n        isinstance(min_val, int)\n        and isinstance(max_val, int)\n        and isinstance(option, bool)\n    ), \"Invalid type of value(s) specified to function!\"\n\n    if min_val > max_val:\n        raise ValueError(\"Invalid value for min_val or max_val (min_value < max_value)\")\n    return min_val if option else max_val\n\n\ndef get_avg(number_1: int, number_2: int) -> int:\n    \"\"\"\n    Return the mid-number(whole) of two integers a and b\n\n    >>> get_avg(10, 15)\n    12\n\n    >>> get_avg(20, 300)\n    160\n\n    >>> get_avg(\"abcd\", 300)\n    Traceback (most recent call last):\n        ...\n    TypeError: can only concatenate str (not \"int\") to str\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/other/guess_the_number_search.py#L36-L72","documentation":"Raised by temp_input_value when min_val is strictly greater than max_val, since the helper returns one endpoint of a valid integer range and an inverted range has no valid endpoints. The function is used by the guess-the-number binary search to seed its bounds.","triggerScenarios":"Calling temp_input_value(min_val=100, max_val=5, ...) or any invocation where min_val > max_val. Types must already be int/bool or the preceding assert fires first.","commonSituations":"Passing user-supplied or config-driven bounds in the wrong order, or swapping arguments positionally (min_val and max_val mixed up).","solutions":["Ensure min_val <= max_val at the call site; swap the arguments if they are reversed","Normalize bounds before calling: lo, hi = sorted((min_val, max_val))"],"exampleFix":"# before\nval = temp_input_value(min_val=100, max_val=5, option=True)  # ValueError\n\n# after\nval = temp_input_value(min_val=5, max_val=100, option=True)","handlingStrategy":"validation","validationCode":"def valid_bounds(min_val: int, max_val: int) -> bool:\n    return isinstance(min_val, int) and isinstance(max_val, int) and min_val <= max_val","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct range arguments in (small, large) order","Normalize bounds once at ingestion: lo, hi = sorted((min_val, max_val))"],"tags":["argument-validation","range-check","game"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}