Your friend Yaʻqūb works the counter at the busiest deli in town, slicing, weighing, and wrapping orders for a never-ending line of hungry customers. To keep things moving, each customer takes a numbered ticket when they arrive.
When it’s time to call the next person, Yaʻqūb reads their number out loud, always in full English words to make sure everyone hears it clearly.
Given a number, your task is to express it in English words exactly as your friend should say it out loud. Yaʻqūb expects to use numbers from 0 up to 999,999,999,999.
Examples:
Sometimes it is necessary to raise an exception. When you do this, you should always include a meaningful error message to indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. For situations where you know that the error source will be a certain type, you can choose to raise one of the built in error types, but should still include a meaningful message.
This particular exercise requires that you use the raise statement to "throw" a ValueError if the number input to say() is out of range. The tests will only pass if you both raise the exception and include a message with it.
To raise a ValueError with a message, write the message as an argument to the exception type:
# if the number is negative
raise ValueError("input out of range")
# if the number is larger than 999,999,999,999
raise ValueError("input out of range")
Sign up to Exercism to learn and master Python with 17 concepts146 exercises, and real human mentoring, all for free.