• + 0 comments

    with regex

    import re phone_numbers = [input() for i in range(int(input()))] pattern = r'^[789]\d{9}$'

    for phone_number in phone_numbers: match = re.match(pattern, phone_number) print("YES" if bool(match) else "NO")

    without regex

    for i in [input() for i in range(int(input()))]: print("NO" if not i.isnumeric() or int(i[0])<7 or len(i)!=10. else "YES")