Print the numbers into words

In this program, we will print numbers into words.

Steps to solve the program
  1. Take a number as input.
  2. User for loop to iterate over a number after converting it into a string using str() and create an empty string.
  3. Add the words with respect to the number to the empty string.
  4. Use if-elif statements for the purpose.
  5. Print the new string which contains numbers in the word form.
				
					num = int(input("Enter a number: "))
str1 = ""

for i in str(num):
    if i == "1":
        str1 += "One"
    elif i == "2":
        str1 += "Two"
    elif i == "3":
        str1 += "Three"
    elif i == "4":
        str1 += "Four"
    elif i == "5":
        str1 += "Five"
    elif i == "6":
        str1 += "Six"
    elif i == "7":
        str1 += "Seven"
    elif i == "8":
        str1 += "Eight"
    elif i == "9":
        str1 += "Nine"
        
print(str1)
				
			

Output :

				
					Enter a number: 236
TwoThreeSix
				
			

find the frequency of each digit in a given integer

find the power of a number

Leave a Comment