from webcolors import name_to_hex
def color_name_to_code(color_name):
try:
color_code = name_to_hex(color_name)
return color_code
except ValueError:
return None
colorname = input("Enter color name : ")
result_code = color_name_to_code(colorname)
print(result_code)
from webcolors import hex_to_name
def color_code_to_name(color_code):
try:
color_name = hex_to_name(color_code)
return color_name
except ValueError:
return None
colorcode = input("Enter color code : ")
result_name = color_code_to_name(colorcode)
print(result_name)
0 Comments:
Post a Comment