Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions exercises/practice/resistor-color-trio/resistor_color_trio.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
def label(colors):
pass

dict = {
"black": 0,
"brown": 1,
"red": 2,
"orange": 3,
"yellow": 4,
"green": 5,
"blue": 6,
"violet": 7,
"grey": 8,
"white": 9
}


def get_color1_index(color1):
if color1 in dict:
for c in dict:
s = dict[color1]
return s
else:
return "The color doesn't exist."

def get_color2_index(color2):
if color2 in dict:
for c in dict:
s = dict[color2]
return s
else:
return "The color doesn't exist."

def value(colors):
color1 = colors[0]
color2 = colors[1]
color3 = colors[2]

ind1 = str(get_color1_index(color1))
ind2 = str(get_color2_index(color2))
ind = ind1 + ind2 +
value = int(ind)
return value

print(value(["brown", "black"]))
print(value(["brown", "black"]) == 10)