We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#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 resultimportreforiinrange(int(input())):num=input()x=re.findall("^[789]\d{9}$", num)iflen(x)>0:print("YES")else:print("NO")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Validating phone numbers
You are viewing a single comment's thread. Return to all comments →