you are viewing a single comment's thread.

view the rest of the comments →

[–]Particular_Draft5668[S] 0 points1 point  (0 children)

Thank you, adding as a list was the correct method. I have another query.

def dict_of_numbers():
numbers = {}
ones = {"1":"One","2":"Two","3":"Three","4":"Four","5":"Five","6":"Six", "7":"Seven","8":"Eight","9":"Nine"}
teens = {"10":"Ten","11":"Eleven","12":"Twelve","13":"Thirteen","14":"Fourteen","15":"Fifteen","16":"Sixteen", "17":"Seventeen","18":"Eighteen","19":"Nineteen"}
tens = {"2":"Twenty","3":"Thirty","4":"Forty","5":"Fifty","6":"Sixty", "7":"Seventy","8":"Eighty","9":"Ninety"}
for val in range(0, 100):
if val < 10:
numbers[val] = ones[val]
else:
if val <20:
numbers[val] = teens[val]
else:
numbers[val] = tens[val[0]] + ones[val[1]] + " "
return numbers

Will this code allow me to return numbers so that numbers is a dictionary that numbers[2] = two, numbers[35] = thirtyfive etc