{"id":25723,"date":"2021-12-04T09:19:46","date_gmt":"2021-12-04T03:49:46","guid":{"rendered":"https:\/\/python-programs.com\/?p=25723"},"modified":"2021-12-04T09:19:46","modified_gmt":"2021-12-04T03:49:46","slug":"python-program-to-convert-a-number-to-words-digit-by-digit","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-convert-a-number-to-words-digit-by-digit\/","title":{"rendered":"Python Program to Convert a Number to Words (digit by digit)"},"content":{"rendered":"

Given a number and the task is to convert the given number into words.<\/p>\n

For Example:<\/strong><\/p>\n

Let number = 15<\/p>\n

The output\u00a0 will be = “one-five”<\/p>\n

Implementation Tips:<\/strong><\/p>\n

Make a global list with words for each digit from 0 to 9. The entries in the list will be mapped to the index, as shown in the table below.<\/p>\n

global list = [ ‘zero’,\u00a0 ‘one’, ……………’Nine’]<\/p>\n

index:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 1 ……………..\u00a0 \u00a0 \u00a09<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given number = 15<\/pre>\n

Output:<\/strong><\/p>\n

The conversion of given number{ 15 } into words = \r\none five<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given number = 678<\/pre>\n

Output:<\/strong><\/p>\n

The conversion of given number{ 678 } into words = \r\nsix seven eight<\/pre>\n

Program to Convert a Number to Words (digit by digit) in Python<\/h2>\n