Input Format
The first line contains , the number of code lines.
The next  lines contains CSS Codes.
Constraints

Output Format
Output the color codes with '#' symbols on separate lines.

hackerrank hex color code problem solution in python programming

Problem solution in Python 3 programming language.

import re

css = ""
for i in range(int(input())):
    css+=input()
    css+='\n'

inside_brackets = re.findall(r'\{.*?\}', css, flags=re.DOTALL)
for property in inside_brackets:
    map(lambda i: print(i,sep='\n',end='\n'),(re.findall(r'#(?:[a-fA-F0-9]{3}|[a-fA-F0-9]{6})\b', property)))

Second solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
N=int(input())
for i in range(0,N):
    s=input()
    x=s.split()
    if len(x)>1  and  '{' not in x:
        x=re.findall(r'#[a-fA-F0-9]{3,6}',s)
        [print(i) for  i in x]

Problem solution in Python 2 programming language.

from __future__ import print_function
import re

css = ""
for i in range(int(raw_input())):
    css+=raw_input()
    css+='\n'

inside_brackets = re.findall(r'\{.*?\}', css, flags=re.DOTALL)
for property in inside_brackets:
    map(lambda i: print(i,sep='\n',end='\n'),(re.findall(r'#(?:[a-fA-F0-9]{3}|[a-fA-F0-9]{6})\b', property)))