File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change 31
31
32
32
33
33
# 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 > ' )
35
35
36
36
hundreds_place = int (numbah )// 100
37
37
lose = int (numbah ) - (hundreds_place * 100 )
38
38
ones_place = int (lose )% 10
39
39
tens_place = int (lose )// 10
40
- print (lose )
40
+ # print(lose)
41
41
42
42
43
43
44
44
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)
49
49
50
50
51
51
single_digits = {
52
- '0' :'zero ' ,
52
+ '0' :'' ,
53
53
'1' :'one' ,
54
54
'2' :'two' ,
55
55
'3' :'three' ,
84
84
'17' :'seventeen' ,
85
85
'18' :'eighteen' ,
86
86
'19' :'nineteen' ,
87
+
87
88
}
88
89
89
90
101
102
}
102
103
103
104
# if numbah:
104
- if hundreds_place == 0 :
105
+ if numbah == "0" :
106
+ print (f'{ numbah } is: zero' )
107
+ elif hundreds_place == 0 :
105
108
if tens_place != 1 :
106
109
print (f'{ numbah } is: { tens_digits [str (tens_place )]} { single_digits [str (ones_place )]} ' )
107
110
if numbah in special_cases :
108
111
print (f'{ numbah } is: { special_cases [numbah ]} ' )
109
- if hundreds_place > 1 :
112
+ elif hundreds_place >= 1 :
110
113
if str (lose ) in special_cases :
111
114
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 :
115
120
print (f'{ numbah } is: { hundreds_digits [str (hundreds_place )]} { tens_digits [str (tens_place )]} { single_digits [str (ones_place )]} ' )
You can’t perform that action at this time.
0 commit comments