Phone Number Word Decoder

Published by Matt in

Create a function 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.
  • Check the Resources tab for more info on telephone keypads.
Watch a quick demo on how Edabit works.