• + 0 comments

    My solution for this in Python 3:

    import re
    re_pattern = r'^[H,h]{1}[I,i]{1}[\s]{1}[^D,d]{1}'
    N = int(input())
    for _ in range(N):
        line = input()
        matched = re.match(re_pattern, line)
        if bool(matched):
            print(line)