{"record":{"id":"1823da317a084329","repo":"TheAlgorithms/Python","slug":"exactly-one-argument-must-be-0-1823da","errorCode":null,"errorMessage":"Exactly one argument must be 0","messagePattern":"Exactly one argument must be 0","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"info","filePath":"electronics/ind_reactance.py","lineNumber":63,"sourceCode":"\n    \"\"\"\n\n    if (inductance, frequency, reactance).count(0) != 1:\n        raise ValueError(\"One and only one argument must be 0\")\n    if inductance < 0:\n        raise ValueError(\"Inductance cannot be negative\")\n    if frequency < 0:\n        raise ValueError(\"Frequency cannot be negative\")\n    if reactance < 0:\n        raise ValueError(\"Inductive reactance cannot be negative\")\n    if inductance == 0:\n        return {\"inductance\": reactance / (2 * pi * frequency)}\n    elif frequency == 0:\n        return {\"frequency\": reactance / (2 * pi * inductance)}\n    elif reactance == 0:\n        return {\"reactance\": 2 * pi * frequency * inductance}\n    else:\n        raise ValueError(\"Exactly one argument must be 0\")\n\n\nif __name__ == \"__main__\":\n    import doctest\n\n    doctest.testmod()\n","sourceCodeStart":45,"sourceCodeEnd":70,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/electronics/ind_reactance.py#L45-L70","documentation":"The final else branch of ind_reactance() raises 'Exactly one argument must be 0'. It is unreachable defensive code: the leading guard `(inductance, frequency, reactance).count(0) != 1` already raises for any input without exactly one zero, so after the three negativity checks one of inductance==0 / frequency==0 / reactance==0 must hold. It exists only as a safety net, and its message text differs from the primary guard's.","triggerScenarios":"Cannot be triggered through the public API for any real inputs; only relevant if the initial count guard is removed/modified or in exhaustive branch-coverage tooling.","commonSituations":"Seen during code review, refactoring, or coverage/mutation testing; a fork that relaxes the first guard would surface the inconsistent second message.","solutions":["No caller action required — the primary ValueError('One and only one argument must be 0') is the one you will observe.","Maintainers: remove the unreachable else or unify its message with the primary guard.","Test suites: exclude this branch from coverage targets rather than contorting inputs to reach it."],"exampleFix":"# before\n    elif reactance == 0:\n        return {\"reactance\": 2 * pi * frequency * inductance}\n    else:\n        raise ValueError(\"Exactly one argument must be 0\")\n\n# after\n    else:  # reactance == 0, the only remaining case\n        return {\"reactance\": 2 * pi * frequency * inductance}","handlingStrategy":"validation","validationCode":"# Guard the reachable primary error instead:\nassert (inductance, frequency, reactance).count(0) == 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Branch is unreachable; test against the 'One and only one argument must be 0' error instead.","Never assert on the 'Exactly one argument must be 0' message — public input cannot produce it."],"tags":["electronics","dead-code","defensive-programming","reactance"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}