• + 0 comments

    This is my code for this problem , i used Pypy 3 instead of Python 3. Below is my code

    import sys
    import re
    
    lista = []
    for line in sys.stdin:
        if(line != ''):
            lista.append(line.rstrip())
    
    for i in range(int(lista[0])):
        try:
            re.compile(lista[i+1])
            is_valid = True
            print('True')
        except re.error:
            is_valid = False
            print('False')