Question: Q1- write a python program, that reads phone numbers input by the user, one per line, without giving a prompt. When the input line is
Q1- write a python program, that reads phone numbers input by the user, one per line, without giving a prompt. When the input line is quit, stop accepting input. As output, print the phone numbers with area code 416, each on a separate line.
The phone numbers are all in one of these two forms:
AAA-XXX-XXXX
or
XXX-XXXX
where AAA is the area code, and XXX-XXXX is the rest. If AAA is missing, it is assumed to be 416; in your program, define 416 as a named value rather than using it as a magic number (that is, create a variable whose value is 416 and use this variable rather than repeatedly using the literal 416). When producing output, add 416 to phone numbers whose area code is missing.
Requirements:
- Use ordinary string operations (not regular expressions) to work with the phone numbers.
- You should have a function that returns true or false depending on whether the area code of a phone number matches.
Example: When the input is:
416-887-2345
905-887-2345
585-4596
quit
The output should be:
416-887-2345
416-585-4596
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
