Write a program that takes a 10-digit phone number and adds a hyphen in the correct location. Using an input field for the user to enter the information. Also, use a string for instructions on how to enter the phone in the input field.

Respuesta :

The python program will request for a ten digit number from the user and formulate a real phone number from it.

How to write a python program to form a real phone number?

The program is written in python.

Therefore,

x = input("please write a ten digit number: ")

if len(x) == 10:

    a = f"({x[0:3]})"

    b = x[3:6]

    c = x[7:]

    print(a + " " + b + "-" + c)

Code explanation:

  • The variable x is used to store the user's input.
  • If the length of x is equals to 10, then we get the first three terms in bracket, the second three terms and the last 4 terms.
  • Finally, we use delimiters to join the variables as required and print it out.  

learn more on python here: brainly.com/question/13462052

#SPJ1

Ver imagen vintechnology
Ver imagen vintechnology
Ver imagen vintechnology
ACCESS MORE