Sort by

recency

|

328 Discussions

|

  • + 0 comments

    This works with PyPy3. Thank you codersaad for the idea. This is the same code but without a function.

    import re

    n = int(input())

    for _ in range(n): regex = input().strip() try: if re.search(r'(*|+|\?){2,}', regex): print("False") else: re.compile(regex) print("True") except re.error: print("False")

  • + 0 comments

    This works with PyPy3. Thank you codersaad for the idea. This is the same code but without a function.

    import re

    n = int(input())

    for _ in range(n): regex = input().strip() try: if re.search(r'(*|+|\?){2,}', regex): print("False") else: re.compile(regex) print("True") except re.error: print("False")

  • + 2 comments

    my solution: import re for i in range(int(input())): try: re.compile(input()) print(True) except re.error: print(False) but it is giving output as TRUE TRUE and hence failing the sample test case. Although i did solve it using python 2 can anyone help me with a pypy3 solution

  • + 0 comments

    This works for Python 3 import re if name == 'main': n = int(raw_input()) for i in range(n): try: re.compile(raw_input()) print("True") except re.error: print("False")

  • + 0 comments

    true true this code is Als gave me