This program will convert from number to word.
For this purpose we are using dictionary data type which is used with key value pairs.
Here the main logic is put into function which is defined by following Syntex.
def fun_name(argument):
def maptoword(number): global list list=[] dic={0:'ZERO',1:'ONE',2:'TWO',3:'THREE',4:'FOUR',5:'FIVE',6:'SIX',7:'SEVEN',8:'EIGHT',9:'NINE'} temp=number while temp!=0: rem=temp%10 list.append(dic[rem]) temp=int(temp/10) i=len(list) i=i-1 while i>=0: print(list.pop(i),end=' ') i=i-1 number=int(input("Enter any number")) maptoword(number)
- OutPut
Enter any number123 ONE TWO THREE