Sort by

recency

|

398 Discussions

|

  • + 0 comments

    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)

  • + 1 comment
    import re
    N=int(input())
    pattern =r'(\#[0-9a-fA-F]{3,6})(;|,|.;)'
    texto=""
    for _ in range (N):
        texto =texto+''.join(input())
    
    matches =re.findall(pattern,texto)
    
    for match in matches:
        print(match[0])
    
  • + 0 comments

    Here is HackerRank Hex Color Code in Python solution - https://programmingoneonone.com/hackerrank-hex-color-code-solution-in-python.html

  • + 0 comments
    1. import re
    2. def check(x):
    3. matches = re.findall(r"#(?:[a-fA-f0-9]{3}|[a-fA-f0-9]{6})(?=[;|,|)])",x)
    4. if matches:
    5. print('\n'.join(matches))
  • + 0 comments
    1. `python
    2. import re
      1. def check(x):
    3. matches = re.findall(r"#(?:[a-fA-f0-9]{3}|[a-fA-f0-9]{6})(?=[;|,|)])",x)
    4. if matches:
    5. for i in range(len(matches)):
    6. print(matches[i])
    7. for i in range(int(input())):
    8. x = input()
    9. check(x)
    10. 14.