-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumbers_as_words_999
34 lines (27 loc) · 1.25 KB
/
numbers_as_words_999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
### Mapping of numbers to words for 1-999 for writing on small cheques ###
one_to_nine = {'1': 'one', '2': 'two', '3': 'three', '4': 'four',
'5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine'}
ten_to_ninety = {
'00': '', '10': 'ten', '11': 'eleven', '12': 'twelve',
'13': 'thirteen', '14': 'fourteen', '15': 'fifteen',
'16': 'sixteen', '17': 'seventeen', '18': 'eighteen',
'19': 'nineteen', '20': 'twenty', '30': 'thirty', '40': 'fourty',
'50': 'fifty', '60': 'sixty', '70': 'seventy', '80': 'eighty',
'90': 'ninety'}
def determine_cheque_wording(integer):
full_word = ''
integer = str(integer)
if len(integer) == 3:
full_word += one_to_nine[integer[0]]
full_word += ' hundred '
integer = integer[1:]
if len(integer) == 2:
if integer not in ten_to_ninety:
int_A = integer[0] + '0'
int_B = integer[1]
full_word += ten_to_ninety[int_A]
full_word += ' '
full_word += one_to_nine[int_B]
elif integer in ten_to_ninety:
full_word += ten_to_ninety[integer]
return full_word + ' money units'