Skip to content

Commit 3509216

Browse files
last bit changed ready to go
1 parent 495b7db commit 3509216

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

code/muki/lab03.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@
3131

3232

3333
# Version 1:
34-
numbah = input('please enter a number between 0 and 999:\n')
34+
numbah = input('please enter a number between 0 and 999:\n> ')
3535

3636
hundreds_place = int(numbah)//100
3737
lose = int(numbah) - (hundreds_place * 100)
3838
ones_place = int(lose)%10
3939
tens_place = int(lose)//10
40-
print(lose)
40+
# print(lose)
4141

4242

4343

4444
print(f'You entered:{numbah}\t Thanks for your entry.')
45-
print(ones_place)
46-
print(tens_place)
47-
print(hundreds_place)
48-
print(lose)
45+
# print(ones_place)
46+
# print(tens_place)
47+
# print(hundreds_place)
48+
# print(lose)
4949

5050

5151
single_digits = {
52-
'0':'zero',
52+
'0':'',
5353
'1':'one',
5454
'2':'two',
5555
'3':'three',
@@ -84,6 +84,7 @@
8484
'17':'seventeen',
8585
'18':'eighteen',
8686
'19':'nineteen',
87+
8788
}
8889

8990

@@ -101,15 +102,19 @@
101102
}
102103

103104
# if numbah:
104-
if hundreds_place == 0:
105+
if numbah == "0":
106+
print(f'{numbah} is: zero')
107+
elif hundreds_place == 0:
105108
if tens_place != 1:
106109
print(f'{numbah} is: {tens_digits[str(tens_place)]}{single_digits[str(ones_place)]}')
107110
if numbah in special_cases:
108111
print(f'{numbah} is: {special_cases[numbah]}')
109-
if hundreds_place > 1:
112+
elif hundreds_place >= 1:
110113
if str(lose) in special_cases:
111114
print(f'{numbah} is: {hundreds_digits[str(hundreds_place)]} {special_cases[str(lose)]}')
112-
if tens_place != 1:
113-
print(f'{numbah} is: {tens_digits[str(tens_place)]}{single_digits[str(ones_place)]}')
114-
if str(lose) not in special_cases:
115+
elif tens_place == 0 and hundreds_place >= 1:
116+
print(f'{numbah} is: {hundreds_digits[str(hundreds_place)]}')
117+
elif tens_place != 1:
118+
print(f'{numbah} is: {hundreds_digits[str(hundreds_place)]} {tens_digits[str(tens_place)]}{single_digits[str(ones_place)]}')
119+
elif str(lose) not in special_cases:
115120
print(f'{numbah} is: {hundreds_digits[str(hundreds_place)]} {tens_digits[str(tens_place)]}{single_digits[str(ones_place)]}')

0 commit comments

Comments
 (0)