-
Notifications
You must be signed in to change notification settings - Fork 319
/
numsConvert.py
39 lines (30 loc) · 1004 Bytes
/
numsConvert.py
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
35
36
37
38
39
#CSci 127 Teaching Staff
#February 2019
#A program that uses functions to print out months.
#Modified by: ADD YOUR NAME HERE
def num2string(num):
"""
Takes as input a number, num, and
returns the corresponding name as a string.
Examples: num2string(0) returns "zero", num2string(1)returns "one"
Assumes that input is an integer ranging from 0 to 9
"""
numString = ""
###################################
### FILL IN YOUR CODE HERE ###
### Other than your name above, ###
### this is the only section ###
### you change in this program. ###
###################################
return(numString)
def main():
nums = input('Enter a multi-digit number: ')
newStr = ""
for n in nums:
word = num2string(int(n))
newStr = newStr + " " + word
msg = 'In words, your number is:' + newStr + "."
print(msg)
#Allow script to be run directly:
if __name__ == "__main__":
main()