Write a program that allows users to enter six-digit RGB color codes and converts them into base 10. In this format, the first two hexadecimal digits represent the amount of red, the second two the amount of green, and the last two the amount of blue. For example: If a user enters FF6347, then the output should be Red (255), Green (99), and Blue (71) in python

Code

def hex_to_rgb(hex):
hex = hex.lstrip('#')
return tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))

if __name__ == "__main__":
hex = input("Enter hex color: ")
print("RGB: %s" % str(hex_to_rgb(hex)))

Output