Format a Phone Number
When a user enters a phone number as separate digits, a program often needs to display it in a familiar readable format. Write create_phone_number, which receives numbers, a list of exactly 10 digits. Return them formatted as (xxx) xxx-xxxx.
Примеры
Ввод
[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]Вывод
"(123) 456-7890"Ввод
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]Вывод
"(000) 000-0000"Ввод
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]Вывод
"(111) 111-1111"Нужно реализовать
def create_phone_number(numbers: list[int]) -> str:
Теги
listsstrings
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inVisible tests
1
Input
[1,2,3,4,5,6,7,8,9,0]Expected
"(123) 456-7890"2
Input
[0,0,0,0,0,0,0,0,0,0]Expected
"(000) 000-0000"3
Input
[1,1,1,1,1,1,1,1,1,1]Expected
"(111) 111-1111"4
Input
[9,8,7,6,5,4,3,2,1,0]Expected
"(987) 654-3210"5
Input
[9,8,7,6,5,4,3,2,1,0,9]Expected
"(987) 654-3210"6
Input
[0]Expected
"(0) -"Focus radio
Paused · SomaFM · Fluid