Currently in Brazil (year 2021), landline numbers are 8 digits long, and cell phone numbers, 9 digits. This number is regional, so to complete an identification of the user in Brazil that a number corresponds, it is also important the area code (DDD), composed of 2 digits. It's common people provide their phone number either including the area code, or not including it. Just following these size rules, some examples of phone numbers valid in Brazil: 21912316165 1132316165 71912316165 323231616 32316165 912316165 Make a function that receives as input a string containing a sequence of digits, which is supposed to it matches the phone number entered by a user (assume this string it only has digits). Your function must identify if the phone number is a valid number in Brazil (what means, if it fits one of the acceptable standards). If so, your function should return a tuple with two strings, the first containing exactly two digits that match the DDD (or empty string, if the area code was not informed), and the second, containing 8 or 9 digits, corresponding to the number without the area code. If the number is invalid, the function must return a tuple with two empty strings.
Currently in Brazil (year 2021), landline numbers are 8 digits long, and cell phone numbers, 9 digits. This number is regional, so to complete an identification of the user in Brazil that a number corresponds, it is also important the area code (DDD), composed of 2 digits. It's common people provide their phone number either including the area code, or not including it. Just following these size rules, some examples of phone numbers valid in Brazil:
21912316165
1132316165
71912316165
323231616
32316165
912316165
Make a function that receives as input a string containing a sequence of digits, which is supposed to it matches the phone number entered by a user (assume this string it only has digits). Your function must identify if the phone number is a valid number in Brazil (what means, if it fits one of the acceptable standards). If so, your function should return a tuple with two strings, the first containing exactly two digits that match the DDD (or empty string, if the area code was not informed), and the second, containing 8 or 9 digits, corresponding to the number without the area code. If the number is invalid, the function must return a tuple with two empty strings.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)