SHARE
TWEET

NumbersToWordForm(1-999)

a guest Nov 14th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # gets the number
  2. numb = input('what number wouldyou like to convert to word form? ')
  3. if len(numb) > 3:
  4.   exit()
  5. nSplit = []
  6. tList = []
  7.  
  8. Result = ''
  9. # lists used to label numbers
  10. basicNumbs= ['one', 'two','three','four','five','six','seven','eigh','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','']
  11. Tensnumbers = ['Twenty','thirty','fourty','fiffty','sixty','sevendy','eighty','nindy','']
  12. Advanced = ['hundred','thousand','million']
  13. # splits your number  into its compents ie, 3, 2, 4 for 324
  14. for n in numb:
  15.   nSplit.append(n)
  16. #Makes a seperate list for the last two numbers and gets rid of them from the orignal
  17.  
  18. for x in range(0 , 3):
  19.   tList.append(nSplit[len(nSplit) + x - 3])
  20.  
  21.  
  22. # finds hte word from for the last two nmbr
  23. if int(tList[0]) < 2:
  24.   badCodeingLmao = int(tList[0])  * 10
  25.   if int(tList[2]) == 0:
  26.     None
  27.   else:
  28.     badCodeingLmao += int(tList[1]) - 1
  29.   Result += basicNumbs[badCodeingLmao]
  30. else:
  31.   badCodeingLmao = int(tList[0])-1
  32.   Result+= basicNumbs[badCodeingLmao] + ' hundred '
  33.   badCodeingLmao = int(tList[1]) - 2
  34.   Result+= Tensnumbers[badCodeingLmao] + ' '
  35.  
  36.   if int(tList[1])== 0:
  37.     badCodeingLmao = 19
  38.  
  39.   else:
  40.     badCodeingLmao = int(tList[2]) - 1
  41.   Result+= basicNumbs[badCodeingLmao] + ' '
  42. print(Result)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top