Skip to content

Commit e7a64f2

Browse files
committed
did revision
1 parent 8cfa450 commit e7a64f2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

code/Andy/python/lab03_number_to_phrases_v2.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44

5+
from requests import request
6+
7+
58
low_numbers = {
69
0: "zero",
710
1: "one",
@@ -85,12 +88,13 @@ def convert_number(number):
8588
if last_one == 0: # its saying that its only calling the last number if it is 0
8689
return f'{ten[tens_digit]}'
8790

88-
elif number < 999:
91+
elif number <= 999:
8992
hundreds_digit = number // 100 #floor divide regular division with no remainder
9093
hundreds_word = hundreds[hundreds_digit]
9194
last_two = int(str(number)[-2:]) #python get last two digits in number stack exchange
9295
last_one = int(str(number)[-1:])
93-
96+
if last_two == 0:
97+
return f'{hundreds_word}'
9498

9599

96100

@@ -109,7 +113,7 @@ def convert_number(number):
109113

110114

111115
# return hundreds_digit, tens_digit
112-
# return f"{hundreds[hundreds_digit]} - {ten[tens_digit]} - {low_numbers[ones_digit]}"
116+
# return f"{hundreds_word} - {ten[tens_digit]} - {low_numbers[ones_digit]}"
113117

114118
print(convert_number(number))
115119

0 commit comments

Comments
 (0)