Sort by

recency

|

487 Discussions

|

  • + 0 comments

    Strange to see such a simple challenge following a few that are more complex. I'm used to challenges being increasingly more complex.

    import re, sys
    
    print('\n'.join(
      ['NO', 'YES']
      [re.match(r'^[789]\d{9}$', l) is not None]
      for l in sys.stdin.readlines()[1:])) 
    
  • + 0 comments

    n = int(input()) # Read number of test cases

    for i in range(n):

    ph_no = input()  # Read each mobile number
    
    if len(ph_no) == 10 and ph_no[0] in ['7', '8', '9'] and ph_no.isdigit():
        print("YES")
    else:
        print("NO")
    
  • + 1 comment

    HackerRank is a great platform for learning how to craft and apply regular expressions in Python. The experience was both challenging and rewarding. Gurubhai247 create account

  • + 1 comment

    n=int(input()) for i in range(n): s=input() a='YES' if len(s)!=10 or s[0] not in '789': a="NO" if any(not j.isdigit() for j in s): a="NO" print(a)

  • + 0 comments
    #import regex package --> iterate through input, use regex "^[789]\d{9}$" to match to input using findall --> finall returns a list, if list size is not 0 then a match has been found, and print according result
    
    import re
    
    for i in range(int(input())):
        num = input()
        x = re.findall("^[789]\d{9}$", num)
        
        if len(x) > 0:
            print("YES")
        else:
            print("NO")