Numbers to English Words and Back

easy
Unit 2 · Strings II0/3 to milestone

Implement:

  • to_words(n) for integers with absolute value below 10¹²: 0 → "zero", 123 → "one hundred twenty-three", 1005 → "one thousand five", -42 → "minus forty-two". Use the scale words thousand, million and billion, hyphenate 21–99, and don't use "and".
  • from_words(text): the inverse, for any string to_words can produce
#strings#recursion#formatting2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Numbers to English Words and Back · TechGradify