Programming Examples

Python program to convert a number entered by the user into its corresponding number in words


Write a program to convert a number entered by the user into its corresponding number in words.

For example, if the input is 876 then the output should be 'Eight Seven Six'.

Solution

num = input ("enter a number = ")
dic = { "0" : "zero" , "1":"one " , "2" : "two" , "3" : "three" , "4" : "four" , "5" : "five" , "6" : "six" , "7" : "seven" , "8" : "eight" , "9" : "nine"}
for i in num :
      print( dic[ i ], end = " ")
Output

enter a number = 456

four five six 

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz