Task 7 of 7 · 0 solved · 7 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

Problem

(Optional) 6.5 Exceptions — capstone: survive bad input

Read two numbers and a word. Print the first number divided by the second — but print 0 instead of crashing if the second is zero. Then print the word turned into a number, or -1 if it is not a number.

For 10 2 42:

5
42

For 5 0 abc:

0
-1
time 1000 ms memory 256 Mb
Solution
Attempts: 0 A hint guides you to the fix — it never writes the code for you.
✦
Ready to check

Press «Submit» to run your code against the task's test cases — that is what sets your score. «AI review» is an optional second opinion: it reads your code — logic and style, not just the output — and suggests the next step without handing over the answer. It never changes your score.

Working…