'''
RGB To Hex Conversion
https://www.codewars.com/kata/513e08acc600c94f01000001/train/python
255, 255, 255 --> "FFFFFF"
255, 255, 300 --> "FFFFFF"
0, 0, 0 --> "000000"
148, 0, 211 --> "9400D3"
'''
def rgb(r,g,b):
ans = ''
for i in [r,g,b]:
if i < 0:
i = 0
elif i > 255:
i = 255
ans += hex(i)[2:].upper().zfill(2)
# hex()函数返回一个整数的十六进制表示,返回字符串
# [2:]去掉前两个字符
# upper()转换字符串中的小写字母为大写
# zfill()返回指定长度的字符串,原字符串右对齐,前面填充0
return ans
'''
a = hex(31)
b = 13
# c = a+b #TypeError: can only concatenate str (not "int") to str
# print(c)
'''