#C13479. Hexadecimal Color Validator
Hexadecimal Color Validator
Hexadecimal Color Validator
You are given a list of strings representing potential hexadecimal color codes. A valid hexadecimal color code must start with a #
sign followed by exactly 3 or 6 hexadecimal characters (digits 0-9 and letters a-f or A-F). In regex terms, a valid color code matches the pattern \( ^\#(?:[0-9a-fA-F]{3}){1,2}$ \).
Your task is to validate each input string and determine if it is a valid hexadecimal color code.
inputFormat
The first line of the input contains an integer \(n\), which indicates the number of color codes to check. Each of the following \(n\) lines contains a single string representing a candidate hexadecimal color code.
outputFormat
For each color code, output a line containing the original string followed by a space and then either "True" if the color code is valid or "False" otherwise.
## sample2
#123
#abc
#123 True
#abc True
</p>