{"record":{"id":"b23a53d84de5c76d","repo":"TheAlgorithms/Python","slug":"color-is-not-a-valid-color-for-multiplier-band","errorCode":null,"errorMessage":"{color} is not a valid color for multiplier band","messagePattern":"(.+?) is not a valid color for multiplier band","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"electronics/resistor_color_code.py","lineNumber":177,"sourceCode":"\n\ndef get_multiplier(color: str) -> float:\n    \"\"\"\n    Function returns the multiplier value associated with the color.\n    Function takes color as input and returns multiplier value\n\n    >>> get_multiplier('Gold')\n    0.1\n\n    >>> get_multiplier('Ivory')\n    Traceback (most recent call last):\n      ...\n    ValueError: Ivory is not a valid color for multiplier band\n\n    \"\"\"\n    if color not in multiplier_color_values:\n        msg = f\"{color} is not a valid color for multiplier band\"\n        raise ValueError(msg)\n    return multiplier_color_values[color]\n\n\ndef get_tolerance(color: str) -> float:\n    \"\"\"\n    Function returns the tolerance value associated with the color.\n    Function takes color as input and returns tolerance value.\n\n    >>> get_tolerance('Green')\n    0.5\n\n    >>> get_tolerance('Indigo')\n    Traceback (most recent call last):\n      ...\n    ValueError: Indigo is not a valid color for tolerance band\n\n    \"\"\"\n    if color not in tolerance_color_values:","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/electronics/resistor_color_code.py#L159-L195","documentation":"Thrown by get_multiplier() in electronics/resistor_color_code.py when color is not a key of multiplier_color_values. The multiplier band accepts the ten digit colors plus Gold (0.1) and Silver (0.01), so any other name (Ivory, Aqua, ...) is rejected. Casing must match the table exactly.","triggerScenarios":"get_multiplier('Ivory'); get_multiplier('gold') if the table keys are capitalized; passing a color that is only valid for tolerance or temperature-coefficient bands.","commonSituations":"Free-text color input from users or a UI color picker using CSS/X11 names; sending the whole band list where the tolerance color ends up in the multiplier slot; spelling variants (Grey/Gray) not matching the table keys.","solutions":["Use a color from the multiplier table, e.g. get_multiplier('Gold') -> 0.1 or get_multiplier('Red') -> 100.0.","Validate membership against the table keys (or a copied list of them) before calling.","Canonicalize user input: strip whitespace, title-case, and map spelling variants to the library's names."],"exampleFix":"# before\nget_multiplier('Ivory')  # ValueError\n\n# after\nget_multiplier('Gold')   # 0.1\nget_multiplier('Orange') # 1000.0","handlingStrategy":"type-guard","validationCode":"MULTIPLIER_COLORS = {'Black','Brown','Red','Orange','Yellow','Green','Blue','Violet','Grey','White','Gold','Silver'}\nif color not in MULTIPLIER_COLORS:\n    raise ValueError(f'{color!r} is not a multiplier-band color')","typeGuard":"def is_multiplier_color(color: str) -> bool:\n    return color in multiplier_color_values","tryCatchPattern":"try:\n    m = get_multiplier(color)\nexcept ValueError as exc:\n    # unknown color name; fall back to prompting the user again\n    ...","preventionTips":["Restrict UI input to the multiplier color set (includes Gold/Silver).","Title-case and trim user input before passing.","Remember Gold=0.1 and Silver=0.01 are valid multipliers here."],"tags":["electronics","resistor","color-code","multiplier","valueerror"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}