Program to convert Number in characters | Python3 program to convert number in characters ; To calculate the reverse of the number ; The remainder will give the last digit of the number ; Extract the first digit of the reversed number ; Match it with switch case ; Divide the number by 10 to get the next number ; Driver code
def NumbertoCharacter ( n ) : NEW_LINE INDENT rev = 0 ; r = 0 ; NEW_LINE while ( n > 0 ) : NEW_LINE INDENT r = n % 10 ; NEW_LINE rev = rev * 10 + r ; NEW_LINE n = n // 10 ; NEW_LINE DEDENT while ( rev > 0 ) : NEW_LINE INDENT r = rev % 10 ; NEW_LINE switcher = { 0 : " zero ▁ " , 1 : " one ▁ " , 2 : " two ▁ " , 3 : " three ▁ " , 4 : " four ▁ " , 5 : " five ▁ " , 6 : " six ▁ " , 7 : " seven ▁ " , 8 : " eight ▁ " , 9 : " nine ▁ " } NEW_LINE print ( switcher . get ( r , " UnValid " ) , end = " ▁ " ) ; NEW_LINE rev = rev // 10 ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 12345 ; NEW_LINE NumbertoCharacter ( n ) ; NEW_LINE DEDENT