=====Problem Statement=====
You are given a string S.
Your task is to find out whether is a valid regex or not.

=====Input Format=====
The first line contains integer T, the number of test cases.
The next T lines contains the string S.

=====Constraints=====
0<T<100

=====Output Format=====
Print "True" or "False" for each test case without quotes.

Difficulty: introductory

Starter code:

# Enter your code here. Read input from STDIN. Print output to STDOUT

Solutions:
import re
n = int(input())
for i in range(n):
    s = input()
    try:
        re.compile(s)
        print(True)
    except Exception as e:
        print(False)


#!/usr/bin/env python3

import re

def __starting_point():
    t = int(input().strip())
    
    for _ in range(t):
        try:
            re.compile(input().strip())
            res = True
        except BaseException:
            res = False
        print(res)
__starting_point()