CodeNewbie Community 🌱

Cover image for Python 🐍 challenge_24βš”οΈ
Mahmoud_Essam
Mahmoud_Essam

Posted on

Python 🐍 challenge_24βš”οΈ

Create Phone Number

  • Write a function that accepts an array of 10 integers (between 0 and 9).
  • That returns a string of those numbers in the form of a phone number.

Examples:

create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) 
    # => returns "(123) 456-7890"
Enter fullscreen mode Exit fullscreen mode

Notes:

  • The returned format must be correct in order to complete this challenge.
  • Don't forget the space after the closing parentheses!
Task URL: Link

My Solution:

def create_phone_number(phone_number) -> str:

    if isinstance(phone_number, list) and len(phone_number) == 10:

        phone: str = str([number for number in phone_number])
        pn: str = phone.replace(',', "").replace(' ', '')

        return f"({pn[1:4]}) {pn[4:7]}-{pn[7:11]}"
    else:
        return "Something went wrong"

Enter fullscreen mode Exit fullscreen mode

Learn Python

Python top free courses from CourseraπŸπŸ’―πŸš€

πŸŽ₯

Connect with Me 😊

πŸ”— Links

linkedin

twitter

Latest comments (1)

Collapse
 
euse44 profile image
euse44

In addition to voice communications, VoIP phone systems can also support Fax over IP (FoIP) functionalities. FoIP allows for the transmission of faxes over the internet, eliminating the need for traditional fax machines VoIP phone services. VoIP phone systems can implement secure FoIP protocols, such as T.38, which encrypts fax data during transmission, ensuring the confidentiality of sensitive documents.