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 18:30
What is outfitting a workplace with video in a technology
Answers: 2
question
Computers and Technology, 24.06.2019 15:30
What type of forensic evidence was recovered during the bomb set off at the new mexico facility on the video that was similar to the evidence obtained at the boston bombings and how did the evidence allow the researchers to connect other pieces of evidence to the same bomb?
Answers: 2
question
Computers and Technology, 24.06.2019 17:00
Anew author is in the process of negotiating a contract for a new romance novel. the publisher is offering three options. in the first option, the author is paid $5,000 upon delivery of the final manuscript and $20,000 when the novel is published. in the second option, the author is paid 12.5% of the net price of the novel for each copy of the novel sold. in the third option, the author is paid 10% of the net price for the first 4,000 copies sold, and 14% of the net price for the copies sold over 4,000. the author has some idea about the number of copies that will be sold and would like to have an estimate of the royal- ties generated under each option. write a program that prompts the author to enter the net price of each copy of the novel and the estimated number of copies that will be sold. the program then outputs he royalties under each option and the best option the author could choose. (use appropriate named constants to store the special values such as royalty rates and fixed royalties.
Answers: 1
question
Computers and Technology, 25.06.2019 12:00
If you fear you have been abusive to a partner, what can you do?
Answers: 2
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
Mathematics, 16.10.2019 23:00
question
Chemistry, 16.10.2019 23:00
Questions on the website: 13722367