subject

Fill in the function problem1. This function should return True if the input string is a valid phone number and False if not. We define a valid phone number as follows: First, it contains an optional area code (3 digits) followed by 7 digits.
Second, there could be one of several possible formats for the phone number, where the Xs are digits:
(XXX) XXX-
XXX-XXX-
XXX-
ANY other format should not count as a valid phone number. Spaces before or after an otherwise number is considered invalid.
Remember that (, ), - and . are special characters for regular expressions. To search for those characters, you need to precede them with a backslash: \( \), \-, \..
Because we are looking for the entire string to be a phone number, you can either use ^ and $ to force a match to be at the beginning and end of a string, or you can use fullmatch instead of match or search.
Where problem1 is : (you can assume import re is already there)
def problem1(searchstring):
"""
Match phone numbers.
:param searchstring: string
:return: True or False
"""
pass'

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:00
How can i clip a picture to a question on the computer?
Answers: 1
question
Computers and Technology, 22.06.2019 09:50
17. implement the jvm dload instruction for the mic-2. it has a 1-byte index and pushes the local variable at this position onto the stack. then it pushes the next higher word onto the stack as well
Answers: 2
question
Computers and Technology, 22.06.2019 11:00
The editing of digital photos us about the same level of difficulty as editing an analog photo
Answers: 2
question
Computers and Technology, 22.06.2019 14:30
The β€œrule of 72” is used to approximate the time required for prices to double due to inflation. if the inflation rate is r%, then the rule of 72 estimates that prices will double in 72/r years. for instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. write a program to test the accuracy of this rule. for each interest rate from 1% to 20%, the program should display the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (assume prices increase at the end of each year.)
Answers: 1
You know the right answer?
Fill in the function problem1. This function should return True if the input string is a valid phone...
Questions
question
History, 08.04.2020 20:56
question
Mathematics, 08.04.2020 20:56
question
Mathematics, 08.04.2020 20:56
question
Mathematics, 08.04.2020 20:56
question
English, 08.04.2020 20:56
Questions on the website: 13722363