October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function, when passed a string such as “six hundred twenty two,” should return the numerical value. It should handle numbers up to 999,999,999.
This function ignores the word “and” anywhere it appears in the input string.
1. """ Define a dictionary mapping between English words 2. and the corresponding numbers. 3. """ 4. digitmap = { 5. "zero" : 0, 6. "one" : 1, 7. "two" : 2, 8. "three" : 3, 9. "four" : 4, 10. "five" : 5, 11. "six" : 6, 12. "seven" : 7, 13. "eight" : 8, 14. "nine" : 9, 15. "ten" : 10, 16. "eleven" : 11, 17. "twelve" : 12, 18. "thirteen" : 13, 19. "fourteen" : 14, 20. "fifteen" ...
Read now
Unlock full access