forked from fenyx-it-academy/Class5-Python-Module-Week3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq2.py
More file actions
23 lines (20 loc) · 818 Bytes
/
q2.py
File metadata and controls
23 lines (20 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# ## 2-reading_number.py
# Write a function that outputs the transcription of an input number with two digits.
# Example:
# ```
# 28---------------->Twenty Eight
reading1=['','One','Two','Three','Four','Five','Six','Seven','Eight','Nine']
reading2=['Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety']
reading3=['Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen']
def reading_numb():
x=input("A number only with two digits: ")
if x.isdigit()==False:
read= x
elif int(x)<10 or int(x)>99:
read= x
elif 20>int(x)>=10:
read='{}--------->{}'.format(x,reading3[int(x[1])])
else:
read='{}--------->{} {}'.format(x,reading2[int(x[0])-2],reading1[int(x[1])])
return read
print(reading_numb())