File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -51,26 +51,15 @@ def resistor_label(colors: list[str]) -> str:
5151 :rtype: str
5252 :raises KeyError: If an unknown color is provided.
5353 """
54- prefix : str = ""
5554 postfix : str = ""
5655 max_tolerance : str = ""
5756
5857 if len (colors ) == 1 :
59- prefix : str = f"{ COLOR_VALUES [colors [0 ]]} "
60-
61- if len (colors ) == 4 :
62- prefix : str = f"{ COLOR_VALUES [colors [0 ]]} { COLOR_VALUES [colors [1 ]]} "
63- postfix = f"{ '0' * COLOR_VALUES [colors [2 ]]} "
64- max_tolerance = MAX_TOLERANCE [colors [3 ]]
65-
66- if len (colors ) == 5 :
67- prefix = (
68- f"{ COLOR_VALUES [colors [0 ]]} "
69- f"{ COLOR_VALUES [colors [1 ]]} "
70- f"{ COLOR_VALUES [colors [2 ]]} "
71- )
72- postfix = f"{ '0' * COLOR_VALUES [colors [3 ]]} "
73- max_tolerance = MAX_TOLERANCE [colors [4 ]]
58+ prefix = f"{ COLOR_VALUES [colors [0 ]]} "
59+ else :
60+ prefix = "" .join (str (COLOR_VALUES [color ]) for color in colors [:- 2 ])
61+ postfix = f"{ '0' * COLOR_VALUES [colors [- 2 ]]} "
62+ max_tolerance = MAX_TOLERANCE [colors [- 1 ]]
7463
7564 int_val : int = int (prefix + postfix )
7665
You can’t perform that action at this time.
0 commit comments