Problem 126411 · easy · Level 01 Prerequisites & Setup

Pretty Phone Number

strings · slicing · f-strings

A form collects phone numbers as ten plain digits. Given a string digits of exactly 10 digit characters, return it in the form (AAA) BBB-CCCC, where AAA are the first three digits, BBB the next three and CCCC the last four.

Examples

Input:  digits = "5551234567"
Output: "(555) 123-4567"

Input:  digits = "0000000000"
Output: "(000) 000-0000"

Constraints

  • len(digits) == 10
  • digits contains only the characters 0-9

Goals

  • Cut a string into fixed-size pieces with slices
  • Assemble a formatted string
Starting Python…