Intro Bite 10. Type conversion and exception handling
Login and get codingIn this Bite you complete the
divide_numbersfunction that takes anumeratorand adenominator(the number above and below the line respectively when doing a division).First you try to convert them to
ints, if that raises aValueErroryou will re-raise it (usingraise).To keep things simple we can expect this function to be called with
int/float/strtypes only (read the tests why ...)Getting passed that exception (no early bail out, we're still in business) you try to divide
numeratorbydenominatorreturning its result.If
denominatoris 0 though, Python throws another exception. Figure out which one that is and catch it. In that case return 0.
2556 out of 2611 users completed this Bite.
Will you be the 2557th person to crack this Bite?
Resolution time: ~28 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪