# Problem 17

Problem:

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are  3 + 3 + 5 + 4 + 4 = 19 letters used in total.

If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?

NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of “and” when writing out numbers is in compliance with British usage.

My Solution:

```
## took me 20 minutes to figure out forty wasn't spelled fourty
d = dict()
d=''
d='one'
d='two'
d='three'
d='four'
d='five'
d='six'
d='seven'
d='eight'
d='nine'
d='ten'
d='eleven'
d='twelve'
d='thirteen'
d='fourteen'
d='fifteen'
d='sixteen'
d='seventeen'
d='eighteen'
d='nineteen'
d='onethousand'

for n in range(20,100):
if len(str(n))==2:
if str(n)=='2':
d[n]='twenty'+d[int(str(n))]
if str(n)=='3':
d[n]='thirty'+d[int(str(n))]
if str(n)=='4':
d[n]='forty'+d[int(str(n))]
if str(n)=='5':
d[n]='fifty'+d[int(str(n))]
if str(n)=='6':
d[n]='sixty'+d[int(str(n))]
if str(n)=='7':
d[n]='seventy'+d[int(str(n))]
if str(n)=='8':
d[n]='eighty'+d[int(str(n))]
if str(n)=='9':
d[n]='ninety'+d[int(str(n))]

for n in range(100,1000):
if int(str(n)[1:])==0:
d[n] = d[int(str(n))]+'hundred'
else:
d[n]=d[int(str(n))]+'hundredand'+d[int(str(n)[1:])] ## int turns e.g. 04 to 4

s=0
for v in d.values():
s += len(v)
#print(v)
print(s)

```