We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Regex and Parsing
- Hex Color Code
- Discussions
Hex Color Code
Hex Color Code
Sort by
recency
|
398 Discussions
|
Please Login in order to post a comment
import re N = int(input()) A = [] for i in range(N): A.append(input()) text = ''.join(A).replace(" ",'') #To Replace all the white spaces pattern = r'#(?:[0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})(?!{)\b' # codes = re.findall(pattern, text) for code in list(codes): print(code)
Here is HackerRank Hex Color Code in Python solution - https://programmingoneonone.com/hackerrank-hex-color-code-solution-in-python.html