Write a Python program that given an integer value outputs a
Write a Python program that, given an integer value, outputs a string with the equivalent English text of each digit. For example, 4 is four, 12 is one two, and 8382 is eight three eight two.
A code has been provided for you. In particular, the user interface in the main() function has been written for you. Your goal is to complete the convert(number_str) function, where number_str holds the number (stored as a string) to convert to the equivalent English text of each digit. See comments in the q1.py code.
Please use Python 3.5: the provided code is here in this link:
https://repl.it/EAgX/0
you can continue working on the code on the website and then share the link. This way it\'s easier, because if you copy the code and post it here it would mess up the indentation.
Programming tips. If you used a lot of if-elif-else statements in your program, you can shorten your solution by using lists. That is, make sure to take advantage of a list such as [’zero’, ’one’, ’two’, ’three’, ’four’, ’five’, ’six’, ’seven’, ’eight’, ’nine’] in your program.
Solution
#Sorry but we are not allowed to post outside links in out answers in chegg.
def convert(number_str):
\'\'\'
Input: number_str is a string of digits.
Output: Returns a string called result
containing the equivalent English text of
each digit in number_str.
Example: If the parameter number_str is
\'893\', then the string \'eight nine three\'
is returned through the variable result.
\'\'\'
result = \'\'
# Enter your code here.
li = [\'zero\', \'one\', \'two\', \'three\', \'four\', \'five\', \'six\', \'seven\', \'eight\', \'nine\']
for i in number_str:
result = result + li[int(i)] +\' \'
result = result[:-1]
return result
def main():
\'\'\' The program driver. \'\'\'
user_input = input(\'> \')
while user_input != \'quit\':
print(convert(user_input))
user_input = input(\'> \')
main()
