take #FFFFFF and rgb(255, 255, 255) The two forms of strings are converted to each other .
Input multiple lines , Each line looks like a string in the title .
Ensure that the string is shaped like #[num1][num2][num3] perhaps rgb([num1], [num2], [num3]).
For the corresponding input , Output a string in another format .
#FFFFFF
rgb(255, 255, 255)
rgb(255, 255, 255)
#FFFFFF
while(1):
try:
inputstr=input()
if(inputstr[0]=="#"):
str1=inputstr[1:3]
str2=inputstr[3:5]
str3=inputstr[5:7]
num1=int('0x'+str1,16)
num2=int('0x'+str2,16)
num3=int('0x'+str3,16)
print("rgb(%s, %s, %s)" % (str(num1),str(num2),str(num3)))
else:
list=inputstr.split(',')
str1=list[0][4:]
str2=list[1][1:]
str3=list[2][1:-1]
# hex Returned letters A~F All lowercase letters a~f, Output according to the sample , use upper The function converts all letters to uppercase
hex1=hex(int(str1))[2:].upper()
hex2=hex(int(str2))[2:].upper()
hex3=hex(int(str3))[2:].upper()
# Decimal rotation 16 There will be a default zero when the base is zero , use rjust Function to fill the left side of the string 0
# Empathy ljust Function to fill in the right side of a string 0
hex1 = hex1.rjust(2, '0')
hex2 = hex2.rjust(2, '0')
hex3 = hex3.rjust(2, '0')
outputstr="#"
outputstr=outputstr+hex1+hex2+hex3
print(outputstr)
except:
break