{"record":{"id":"d38f5979262306aa","repo":"TheAlgorithms/Python","slug":"no-input-value-was-provided","errorCode":null,"errorMessage":"No input value was provided","messagePattern":"No input value was provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"conversions/decimal_to_binary.py","lineNumber":96,"sourceCode":"    for positive and negative integers respectively.\n    >>> decimal_to_binary_recursive(0)\n    '0b0'\n    >>> decimal_to_binary_recursive(40)\n    '0b101000'\n    >>> decimal_to_binary_recursive(-40)\n    '-0b101000'\n    >>> decimal_to_binary_recursive(40.8)\n    Traceback (most recent call last):\n        ...\n    ValueError: Input value is not an integer\n    >>> decimal_to_binary_recursive(\"forty\")\n    Traceback (most recent call last):\n        ...\n    ValueError: Input value is not an integer\n    \"\"\"\n    number = str(number).strip()\n    if not number:\n        raise ValueError(\"No input value was provided\")\n    negative = \"-\" if number.startswith(\"-\") else \"\"\n    number = number.lstrip(\"-\")\n    if not number.isnumeric():\n        raise ValueError(\"Input value is not an integer\")\n    return f\"{negative}0b{decimal_to_binary_recursive_helper(int(number))}\"\n\n\nif __name__ == \"__main__\":\n    import doctest\n\n    doctest.testmod()\n\n    print(decimal_to_binary_recursive(input(\"Input a decimal number: \")))\n","sourceCodeStart":78,"sourceCodeEnd":110,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/conversions/decimal_to_binary.py#L78-L110","documentation":"Raised by decimal_to_binary_recursive(number) in conversions/decimal_to_binary.py:96 when, after str(number).strip(), the value is empty. The function's contract is to stringify whatever it receives, so an empty string, a blank string, or None-adjacent empty input means there is no number to convert and it fails fast with a ValueError.","triggerScenarios":"decimal_to_binary_recursive(''), decimal_to_binary_recursive('   '), or passing an empty form field / blank CLI input / empty environment variable.","commonSituations":"The module's own __main__ block calls decimal_to_binary_recursive(input(...)) — pressing Enter on an empty prompt triggers exactly this; web forms where a numeric field was left blank.","solutions":["Check for blank input before calling: if not str(value).strip(): handle the empty case in your UI/logic","Provide a default: value = value.strip() or '0'","Wrap interactive input in a loop that re-prompts until non-empty"],"exampleFix":"# before\nprint(decimal_to_binary_recursive(input('num: ')))  # Enter -> ValueError\n\n# after\nraw = input('num: ').strip()\nif not raw:\n    raise SystemExit('a number is required')\nprint(decimal_to_binary_recursive(raw))","handlingStrategy":"validation","validationCode":"if not str(number).strip():\n    raise ValueError('a decimal number is required')","typeGuard":null,"tryCatchPattern":"try:\n    decimal_to_binary_recursive(number)\nexcept ValueError as e:\n    if 'No input value' in str(e):\n        number = '0'  # or re-prompt\n    else:\n        raise","preventionTips":["Check required form/CLI fields for blank before conversion","Re-prompt on empty interactive input instead of passing it through","Default optional numeric inputs explicitly rather than letting '' propagate"],"tags":["python","value-error","binary","empty-input"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}