← Back to challenges

Numbers to English

PythonHardalgorithmsdata_structuresstrings

Instructions

Write a function that accepts a positive integer between 0 and 999 inclusive and returns a string representation of that integer written in English.

Examples

num_to_eng(0) ➞ "zero"

num_to_eng(18) ➞ "eighteen"

num_to_eng(126) ➞ "one hundred twenty six"

num_to_eng(909) ➞ "nine hundred nine"

Notes

  • There are no hyphens used (e.g. "thirty five" not "thirty-five").
  • The word "and" is not used (e.g. "one hundred one" not "one hundred and one").
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.