Write program use a loop to ask the user to enter a series


Problem

This program will test your ability to examine and manipulate strings. Create file named Lab07P1.py. Write program that does the following: Use a loop to ask the user to enter a series of phone numbers in a specific format: ###-###-####.

For example, 800-555-1212. You will need to validate that the phone number is in the correct format. Check for these validation conditions

IN THIS ORDER:

1. Check whether the user entry has exactly two dashes. If it doesn't, display an appropriate error message and continue in the loop. Do not check on other error conditions.

2. Check whether the first part of the phone number is a three-digit number. If it is not, display an appropriate error message and continue in the loop without checking other error conditions.

3. Check whether the second part of the phone number is a three-digit number. If it is not, display an appropriate error message and continue in the loop without checking other error conditions.

4. Check whether the last part of the phone number is a four-digit number. If it is not, display an appropriate error message and continue in the loop without checking other error conditions.

5. Check whether the number in the first part of the phone number is between 200 and 999 inclusive. If it is not, display an appropriate error message and continue in the loop without checking other error conditions. If the phone number entered was valid, then change the dashes to periods and display the newly formatted phone number. For example, if the phone number was: 800-555-1212 ...the program should display: 800.555.1212 The program will continue asking the user for phone numbers until they enter a q or Q to exit the program.

Sample output:

Enter phone number or q to quit: 444-333.5555
Phone number should have 2 dashes.
Enter phone number or q to quit: 44-333-5555
First part of phone number must be a 3-digit number.
Enter phone number or q to quit: 444-3s3-5555
Second part of phone number must be a 3-digit number.
Enter phone number or q to quit: 444-333-888
Last part of phone number must be a 4-digit number.
Enter phone number or q to quit: 444-333-5555
Phone number with dashes replaced: 444.333.5555
Enter phone number or q to quit: 122-333-5555
First 3 digits must be between 200 and 999.
Enter phone number or q to quit: 7777-333-2222
First part of phone number must be a 3-digit number.
Enter phone number or q to quit: 800-555-1212
Phone number with dashes replaced: 800.555.1212
Enter phone number or q to quit: q

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Write program use a loop to ask the user to enter a series
Reference No:- TGS03249151

Expected delivery within 24 Hours