작성
·
29
0
코딩 아무것도 모르는 초보자입니다
chatgpt로 해당 색깔을 넣으면 색깔에 범위를 정해주는 코딩을 하고 있는데
def is_within_range(test_color, lower, upper):
return all(lower[i] <= test_color[i] <= upper[i] for i in range(3))
color_ranges = {
"Nuga": ((200, 120, 50), (220, 160, 100)),
"Light green": ((0, 140, 0), (50, 180, 60)),
"Medium blue": ((40, 110, 180), (60, 150, 210)),
"Apple green": ((100, 180, 0), (140, 220, 50)),
"Dark brown": ((30, 20, 10), (70, 50, 40)),
"Dark Azur": ((0, 0, 200), (20, 50, 255)),
"Lavender": ((180, 150, 200), (220, 200, 240)),
"White": ((240, 240, 240), (255, 255, 255)),
"Black": ((0, 0, 0), (30, 30, 30)),
"Dark Gray": ((50, 50, 50), (100, 100, 100)),
"Light Gray": ((140, 140, 140), (180, 180, 180)),
"Red": ((180, 20, 20), (210, 60, 60)),
"Yellow": ((240, 180, 20), (255, 220, 60)),
"Blue": ((10, 100, 180), (30, 140, 220)),
"Green": ((20, 100, 30), (50, 160, 70)),
"Orange": ((200, 80, 0), (240, 120, 50)),
"Tan": ((150, 130, 100), (190, 180, 140)),
"Purple": ((60, 20, 100), (100, 60, 160)),
"Brown": ((150, 90, 60), (190, 120, 100)),
"Dark Red": ((160, 40, 60), (190, 80, 100)),
"Earth blue": ((10, 40, 70), (30, 70, 120)),
"Sky Blue": ((50, 140, 180), (80, 180, 220)),
"Pink": ((200, 150, 200), (220, 180, 240)),
"Bright teal": ((0, 120, 120), (30, 160, 160)),
"Sand blue": ((80, 120, 150), (110, 160, 190)),
"Earth green": ((0, 50, 10), (20, 90, 50)),
"Watermelon red": ((230, 80, 70), (255, 130, 120)),
"Aqua": ((170, 220, 200), (190, 240, 220)),
"Skin White": ((220, 200, 150), (240, 220, 190)),
}
test_color = (0, 410, 0)
matched_color = None
for color_name, (lower, upper) in color_ranges.items():
if is_within_range(test_color, lower, upper):
matched_color = color_name
break
if matched_color:
print(f"The color {test_color} belongs to '{matched_color}' range.")
else:
print(f"The color {test_color} does not match any predefined range.")
이렇게 chatgpt가 하라고 해서 넣었습니다. 근데 자꾸
File "<python-input-632>", line 3
else:
^^^^
SyntaxError: invalid syntax 오류가 뜨면서 실행이 안됩니다.
혹시 무엇이 잘못이고 고쳐야하는지 알려주실 분들 있나요?
NFT 발행하기
답변