You are viewing a single comment's thread. Return to all comments →
here's how to do it without a branch
import re if __name__ == '__main__': n = int(input()) phone_number = [input() for i in range(n)] is_phone_valid = [] valid_prefix = ['7','8','9'] valid_note = ['NO', 'YES'] for i in phone_number: note = i.isdigit() and i[0] in valid_prefix and len(i)==10 is_phone_valid.append(valid_note[note]) print(*is_phone_valid, sep='\n')
`
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 →
here's how to do it without a branch
`