diff --git a/solutions/python/resistor-color-duo/1/resistor_color_duo.py b/solutions/python/resistor-color-duo/1/resistor_color_duo.py new file mode 100644 index 0000000..f509c98 --- /dev/null +++ b/solutions/python/resistor-color-duo/1/resistor_color_duo.py @@ -0,0 +1,30 @@ +""" +In this exercise you are going to create a helpful program so that +you don't have to remember the values of the bands. The program will +take color names as input and output a two digit number, even if the +input is more than two colors! +""" + +COLORS: tuple = ( + "black", + "brown", + "red", + "orange", + "yellow", + "green", + "blue", + "violet", + "grey", + "white", +) + + +def value(colors: list) -> int: + """ + Take color names as input and output a two digit number, + even if the input is more than two colors. + + :param colors: list of color names + :return: two-digit number + """ + return int("".join(str(COLORS.index(color)) for color in colors[:2]))