Given a non-negative integer n, return a string containing the English word for each digit of n, separated by single spaces, in the order the digits appear.
The digits map to words as follows: 0 -> "Zero", 1 -> "One", 2 -> "Two", 3 -> "Three", 4 -> "Four", 5 -> "Five", 6 -> "Six", 7 -> "Seven", 8 -> "Eight", 9 -> "Nine".
For example, if n = 302, the function should return "Three Zero Two".
Function Signature
def convert_digits_to_words(n: int) -> str:
Rules
-
Use each word exactly as spelled and capitalized in the mapping above.
-
Separate consecutive words with exactly one space. The result has no leading or trailing space.
-
n
is read in base 10 without leading zeros, so
n = 0
produces the single word "Zero".
Constraints
Examples
Input: n = 302
Output: "Three Zero Two"
The digits are 3, 0 and 2, which map to "Three", "Zero" and "Two". The zero in the middle still gets its own word.
Input: n = 1234
Output: "One Two Three Four"
The digits 1, 2, 3 and 4 map to "One", "Two", "Three" and "Four", kept in the order they appear.
Input: n = 0
Output: "Zero"
Zero has one digit, so the result is a single word with no spaces.