total = 0 #First sum letter count for 1 - 9 and multiply to cover ones digits (except in teens) and "___ hundred." oThruN = "onetwothreefourfivesixseveneightnine" total += len(oThruN) * 190 #Now add in teens. teens = "eleventwelvethirteenfourteenfifteensixteenseventeeneighteennineteen" total += len(teens) * 10 #Cover tens digits except for teens and ten. tens = "twentythirtyfortyfiftysixtyseventyeightyninety" total += len(tens) * 100 #Add in all the word "ten." total += 3 * 10 #Add in the word "and." total += 3 * 891 #Add in the word "hundred." total += 7 * 900 #Add in 1000. thousand = "onethousand" total += len(thousand) print total
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question