Sort by

recency

|

469 Discussions

|

  • + 0 comments
    import re
    
    N = int(input())
    
    phone_number_list = [ input() for i in range(N) ]
    
    for phone_number in phone_number_list:
        if len(phone_number) == 10 and phone_number.isdigit() and re.match(r"^[789](\d)", phone_number):
            print("YES")
        else:
            print("NO")
    
  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    import re
    
    # Define regex to start with 7-9, followed with 9 digits
    regex = "^[7-9][0-9]{9}$"
    
    n = int(input())
    numbers = []
    
    for i in range(n):
        numbers.append(input())
        
    for number in numbers:
        if re.match(regex, number):
            print("YES")
        else:
            print("NO")
            
    
  • + 0 comments

    With the help of comprehension lists -->

    import sys, re
    
    N = sys.stdin.read().splitlines()[1:]
    pattern = r"^[789]\d{9}$"
    
    match = ['YES' if re.search(pattern, line) else 'NO' for line in N]
    
    for _ in match:
        print(_)
    
  • + 0 comments
    import re
    for i in range(int(input())):
        print('YES' if re.search(r'^[789]\d{9}$', input()) else 'NO')
    
  • + 0 comments

    def num(): n = int(input()) for _ in range (n): num=input().strip() if len (num)==10 and num[0] in "7,8,9" and num.isdigit(): print("YES") else: print("NO") num()