Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function called PhoneNumberFormar that takes a string containing a ten-digit phone number (such as 5155551212) as input, convert into a more readable string
Write a function called "PhoneNumberFormar that takes a string containing a ten-digit phone number (such as 5155551212) as input, convert into a more readable string with parentheses and dashes like (515)555-1212 and display it If the input string contains more than or less than ten characters, display an error message Note: Steps ofphoneNumberFormat function can be given as follows: def phoneNumberFormat (phoneNum): 1. Let 1 be the length of the phoneNum 2. If 1 not equals 10 then, display an error message 3. Otherwise, i- areacode = fir3t three characters of phobeNum . next3digitsthe substring ch next three digits of lasttigit3 the substring of the last four digits of iz. Concatenate the subtrings in the order, open parenthesis, phoneNum phoneNum areaCode, close parenthesis, next3digits, dash, lastidigits and display the result
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started