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, 23.06.2019 01:30
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
Jack is assisting his younger sibling mary with her mathematics assignment, which includes a study of the number system. jack explains to mary that whole numbers are counting numbers that could be used to record the number of fruits in a basket. which data type represents whole numbers? a.integers.b.floating-point numbers. c.strings.d.boolean
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
What is a dashed line showing where a worksheet will be divided between pages when it prints? a freeze pane a split box a page break a print title
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
Acontact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. write a program that first takes in word pairs that consist of a name and a phone number (both strings). that list is followed by a name, and your program should output that name's phone number.
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
Business, 20.11.2020 20:20
question
Mathematics, 20.11.2020 20:20
question
Mathematics, 20.11.2020 20:20
question
Mathematics, 20.11.2020 20:20
question
Health, 20.11.2020 20:20
Questions on the website: 13722367