Question

Create a function named list_numbers_in_words(...) which receives as a parameter a positive integer number and returns...

Create a function named list_numbers_in_words(...) which receives as a parameter a positive integer number and returns a list with the words corresponding to each digit, in the same order as the digits appear in the number.

As an example, the following code fragment:

res = list_numbers_in_words(5438) print(res)

should produce the output:

['five', 'four', 'three', 'eight']

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def list_numbers_in_words(n):
    result = []
    numbers = ['zero','one','two','three','four','five','six','seven','eight','nine']
    while(n>0):
        rem = n%10
        n = n//10
        result.append(numbers[rem])
    result = result[::-1]
    return result

# Testing
res = list_numbers_in_words(5438)
print(res)

Add a comment
Know the answer?
Add Answer to:
Create a function named list_numbers_in_words(...) which receives as a parameter a positive integer number and returns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT