← Back to challenges

Phone Number Word Decoder

PythonHardformattinglanguage_fundamentalsstringsregex

Instructions

Create a program that converts a phone number with letters to one with only numbers.

NumberLetter
0none
1none
2ABC
3DEF
4GHI
5JKL
6MNO
7PQRS
8TUV
9WXYZ

Examples

text_to_num("123-647-EYES") ➞ "123-647-3937"

text_to_num("(325)444-TEST") ➞ "(325)444-8378"

text_to_num("653-TRY-THIS") ➞ "653-879-8447"

text_to_num("435-224-7613") ➞ "435-224-7613"

Notes

  • All inputs will be formatted as a string representing a proper phone number in the format XXX-XXX-XXXX or (XXX)XXX-XXXX, using numbers and capital letters.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.