Question: 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
Get step-by-step solutions from verified subject matter experts
